📄 grid.java
字号:
{
colAttr = new GridCellAttributes();
m_mapColAttributes.put(iCol, colAttr);
}
colAttr.m_clrCellBackColor = rowBackColor;
_repaintGridIfNeeded();
}
/**
* Set the column background color
*/
public void clearColBackColor(int iCol)
{
try
{
m_mapColAttributes.get(iCol).m_clrCellBackColor = null;
_repaintGridIfNeeded();
}
catch (Exception e)
{
}
}
/**
* Get the column foreground color
*/
public Color getColForeColor(int iCol)
{
try
{
return m_mapColAttributes.get(iCol).m_clrCellForeColor;
}
catch (Exception e)
{
return null;
}
}
/**
* Set the column foreground color
*/
public void setColForeColor(int iCol, Color rowForeColor)
{
GridCellAttributes colAttr = m_mapColAttributes.get(iCol);
if (colAttr == null)
{
colAttr = new GridCellAttributes();
m_mapColAttributes.put(iCol, colAttr);
}
colAttr.m_clrCellForeColor = rowForeColor;
_repaintGridIfNeeded();
}
/**
* Set the column foreground color
*/
public void clearColForeColor(int iCol)
{
try
{
m_mapColAttributes.get(iCol).m_clrCellForeColor = null;
_repaintGridIfNeeded();
}
catch (Exception e)
{
}
}
/**
* Get the column font
*/
public Font getColFont(int iCol)
{
try
{
return m_mapColAttributes.get(iCol).m_CellFont;
}
catch (Exception e)
{
return null;
}
}
/**
* Set the column font
*/
public void setColFont(int iCol, Font rowFont)
{
GridCellAttributes colAttr = m_mapColAttributes.get(iCol);
if (colAttr == null)
{
colAttr = new GridCellAttributes();
m_mapColAttributes.put(iCol, colAttr);
}
colAttr.m_CellFont = rowFont;
_repaintGridIfNeeded();
}
/**
* Set the column font
*/
public void clearColFont(int iCol)
{
try
{
m_mapColAttributes.get(iCol).m_CellFont = null;
_repaintGridIfNeeded();
}
catch (Exception e)
{
}
}
/**
* Get the column cell type
*/
public Class getColCellType(int iCol)
{
return m_mapColCellTypes.get(iCol);
}
/**
* Set the column cell type
*/
public void setColCellType(int iCol, Class cellType)
{
m_mapColCellTypes.put(iCol, cellType);
boolean bUpdating = m_bUpdating;
m_bUpdating = false;
_recreateColumnCells(iCol, cellType);
m_bUpdating = bUpdating;
_repaintGridIfNeeded();
}
/**
* Clear the column cell type
*/
public void clearColCellType(int iCol)
{
m_mapColCellTypes.remove(iCol);
}
/**
* Get the default cell alignment
*/
public int getDefaultCellAlignment()
{
return m_cellAttributesDefault.m_iCellAlignment;
}
/**
* Set the default cell alignment
*/
public void setDefaultCellAlignment(int iAlignment)
{
if (iAlignment == GridCellAttributes.ALIGN_DEFAULT)
{
return;
}
m_cellAttributesDefault.m_iCellAlignment = iAlignment;
_repaintGridIfNeeded();
}
/**
* Get the default cell background color
*/
public Color getDefaultCellBackColor()
{
return m_cellAttributesDefault.m_clrCellBackColor;
}
/**
* Set the default cell background color
*/
public void setDefaultCellBackColor(Color clrBackColor)
{
if (clrBackColor == null)
{
return;
}
m_cellAttributesDefault.m_clrCellBackColor = clrBackColor;
_repaintGridIfNeeded();
}
/**
* Get the default cell foreground color
*/
public Color getDefaultCellForeColor()
{
return m_cellAttributesDefault.m_clrCellForeColor;
}
/**
* Set the default cell foreground color
*/
public void setDefaultCellForeColor(Color clrForeColor)
{
if (clrForeColor == null)
{
return;
}
m_cellAttributesDefault.m_clrCellForeColor = clrForeColor;
_repaintGridIfNeeded();
}
/**
* Get the default cell font
*/
public Font getDefaultCellFont()
{
return m_cellAttributesDefault.m_CellFont;
}
/**
* Set the default cell font
*/
public void setDefaultCellFont(Font cellFont)
{
if (cellFont == null)
{
return;
}
m_cellAttributesDefault.m_CellFont = cellFont;
_repaintGridIfNeeded();
}
/**
* Get the fixed cell alignment
*/
public int getFixedCellAlignment()
{
return m_cellAttributesFixed.m_iCellAlignment;
}
/**
* Set the fixed cell alignment
*/
public void setFixedCellAlignment(int iCellAlignment)
{
if (iCellAlignment == GridCellAttributes.ALIGN_DEFAULT)
{
return;
}
m_cellAttributesFixed.m_iCellAlignment = iCellAlignment;
_repaintGridIfNeeded();
}
/**
* Get the fixed cell background color
*/
public Color getFixedCellBackColor()
{
return m_cellAttributesFixed.m_clrCellBackColor;
}
/**
* Set the fixed cell background color
*/
public void setFixedCellBackColor(Color clrBackColor)
{
if (clrBackColor == null)
{
return;
}
m_cellAttributesFixed.m_clrCellBackColor = clrBackColor;
_repaintGridIfNeeded();
}
/**
* Get the fixed cell foreground color
*/
public Color getFixedCellForeColor()
{
return m_cellAttributesFixed.m_clrCellForeColor;
}
/**
* Set the fixed cell foreground color
*/
public void setFixedCellForeColor(Color clrForeColor)
{
if (clrForeColor == null)
{
return;
}
m_cellAttributesFixed.m_clrCellForeColor = clrForeColor;
_repaintGridIfNeeded();
}
/**
* Get the fixed cell font
*/
public Font getFixedCellFont()
{
return m_cellAttributesFixed.m_CellFont;
}
/**
* Set the fixed cell font
*/
public void setFixedCellFont(Font cellFont)
{
if (cellFont == null)
{
return;
}
m_cellAttributesFixed.m_CellFont = cellFont;
_repaintGridIfNeeded();
}
/**
* Get the selected cell alignment
*/
public int getSelectedCellAlignment()
{
return m_cellAttributesSelected.m_iCellAlignment;
}
/**
* Set the selected cell alignment
*/
public void setSelectedCellAlignment(int iCellAlignment)
{
m_cellAttributesSelected.m_iCellAlignment = iCellAlignment;
_repaintGridIfNeeded();
}
/**
* Get the selected cell background color
*/
public Color getSelectedCellBackColor()
{
return m_cellAttributesSelected.m_clrCellBackColor;
}
/**
* Set the selected cell background color
*/
public void setSelectedCellBackColor(Color clrBackColor)
{
if (clrBackColor == null)
{
return;
}
m_cellAttributesSelected.m_clrCellBackColor = clrBackColor;
_repaintGridIfNeeded();
}
/**
* Get the selected cell foreground color
*/
public Color getSelectedCellForeColor()
{
return m_cellAttributesSelected.m_clrCellForeColor;
}
/**
* Set the selected cell foreground color
*/
public void setSelectedCellForeColor(Color clrForeColor)
{
if (clrForeColor == null)
{
return;
}
m_cellAttributesSelected.m_clrCellForeColor = clrForeColor;
_repaintGridIfNeeded();
}
/**
* Get the selected cell font
*/
public Font getSelectedCellFont()
{
return m_cellAttributesSelected.m_CellFont;
}
/**
* Set the selected cell font
*/
public void setSelectedCellFont(Font cellFont)
{
m_cellAttributesSelected.m_CellFont = cellFont;
_repaintGridIfNeeded();
}
/**
* Get the grid top displaying row
*/
public int getTopRow()
{
return m_iTopRow;
}
private void _setTopRowEx(int iRow)
{
if (iRow > m_iRowCount - 1)
{
m_iTopRow = m_iRowCount - 1;
}
else
{
m_iTopRow = iRow;
}
_repaintGridIfNeeded();
}
/**
* Set the grid top displaying row
*/
public void setTopRow(int iRow)
{
boolean bUpdating = m_bUpdating;
m_bUpdating = false;
_setTopRowEx(iRow);
m_VertScroll.setValue(m_iTopRow);
m_bUpdating = bUpdating;
_repaintGridIfNeeded();
}
/**
* Get the bottommost displaying row
*/
public int getBottomRow()
{
return m_iBottomRow;
}
/**
* Get if the bottommost displaying row was fully draw
*/
public boolean getBottomRowFullDraw()
{
return m_bBottomRowFullDraw;
}
/**
* Get the grid left displaying column
*/
public int getLeftCol()
{
return m_iLeftCol;
}
private void _setLeftColEx(int iCol)
{
if (iCol > m_iColCount - 1)
{
m_iLeftCol = m_iColCount - 1;
}
else
{
m_iLeftCol = iCol;
}
_repaintGridIfNeeded();
}
/**
* Set the grid left displaying column
*/
public void setLeftCol(int iCol)
{
boolean bUpdating = m_bUpdating;
m_bUpdating = false;
_setLeftColEx(iCol);
m_HorzScroll.setValue(m_iLeftCol);
m_bUpdating = bUpdating;
_repaintGridIfNeeded();
}
/**
* Get the rightmost displaying column
*/
public int getRightCol()
{
return m_iRightCol;
}
/**
* Get if the rightmost displaying column was fully draw
*/
public boolean getRightColFullDraw()
{
return m_bRightColFullDraw;
}
/**
* Get the grid top-left displaying cell object
*/
public GridCell getTopLeftCell()
{
return getCell(m_iTopRow, m_iLeftCol);
}
/**
* Get the grid top-left displaying cell id
*/
public GridCellID getTopLeftCellID()
{
return new GridCellID(m_iTopRow, m_iLeftCol);
}
/**
* Set the grid top-left displaying cell id
*/
public void setTopLeftCellID(GridCellID cellID)
{
if (!cellID.isValid(m_iRowCount, m_iColCount))
{
return;
}
boolean bUpdating = m_bUpdating;
setUpdating(false);
setTopRow(cellID.Row);
setLeftCol(cellID.Col);
setUpdating(bUpdating);
}
/**
* Set the grid top-left displaying cell id
*/
public void setTopLeftCellID(int iRow, int iCol)
{
setTopLeftCellID(new GridCellID(iRow, iCol));
}
/**
* Get all cells from a row
*/
public GridCellHashtable getRowCells(int iRow)
{
return m_Storage.getRowCells(iRow);
}
/**
* Get all cells from a non-fixed row
*/
public GridCellHashtable getNonFixedRowCells(int iNonFixedRow)
{
return m_Storage.getRowCells(m_iFixedRowCount + iNonFixedRow);
}
/**
* Get all cells from a column
*/
public GridCellHashtable getColCells(int iCol)
{
return m_Storage.getColCells(iCol);
}
/**
* Get all cells from a non-fixed column
*/
public GridCellHashtable getNonFixedColCells(int iNonFixedCol)
{
return m_Storage.getColCells(m_iFixedColCount + iNonFixedCol);
}
/**
* Get a grid cell object (creates one if it磗 not already created)
*/
public GridCell getCell(GridCellID cellID)
{
return m_Storage.createCell(cellID);
}
/**
* Get a grid cell object (creates one if it磗 not already created)
*/
public GridCell getCell(int iRow, int iCol)
{
return getCell(new GridCellID(iRow, iCol));
}
/**
* Set a grid cell object
*/
public void setCell(GridCellID cellID, GridCell cell)
{
m_Storage.putCell(cellID, cell);
_repaintGridIfNeeded();
}
/**
* Set a grid cell object
*/
public void setCell(int iRow, int iCol, GridCell cell)
{
setCell(new GridCellID(iRow, iCol), cell);
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -