📄 tableelement.java
字号:
if (font != null)
return font;
// Row Next
font = (Font)m_rowColFont.get(new Point (row, ALL));
if (font != null)
return font;
// Column then
font = (Font)m_rowColFont.get(new Point (ALL, col));
if (font != null)
return font;
// default
return m_baseFont;
} // getFont
/**
* Get Foreground Color.
* @param row row
* @param col column
* @return Color for row/col
*/
private Color getColor (int row, int col)
{
// First specific position
Color color = (Color)m_rowColColor.get(new Point(row, col));
if (color != null)
return color;
// Row Next
color = (Color)m_rowColColor.get(new Point (row, ALL));
if (color != null)
return color;
// Column then
color = (Color)m_rowColColor.get(new Point (ALL, col));
if (color != null)
return color;
// default
return m_baseColor;
} // getFont
/**
* Get Foreground Color.
* @param row row
* @param col column
* @return Color for row/col
*/
private Color getBackground (int row, int col)
{
// First specific position
Color color = (Color)m_rowColBackground.get(new Point(row, col));
if (color != null)
return color;
// Row Next
color = (Color)m_rowColBackground.get(new Point (row, ALL));
if (color != null)
return color;
// Column then
color = (Color)m_rowColBackground.get(new Point (ALL, col));
if (color != null)
return color;
// default
return m_baseBackground;
} // getFont
/*************************************************************************/
/**
* Get Calculated Height on page
* @param pageNo page number
* @return Height
*/
public float getHeight (int pageNo)
{
int pageIndex = getPageIndex(pageNo);
int pageYindex = getPageYIndex(pageIndex);
float pageHeight = ((Float)m_pageHeight.get(pageYindex)).floatValue();
float pageHeightPrevious = 0f;
if (pageYindex > 0)
pageHeightPrevious = ((Float)m_pageHeight.get(pageYindex-1)).floatValue();
float retValue = pageHeight - pageHeightPrevious;
Log.trace(Log.l6_Database, "TableElement.getHeight (" + pageNo + ")",
"PageIndex=" + pageIndex + ", PageYindex=" + pageYindex + ", Height=" + String.valueOf(retValue));
return retValue;
} // getHeight
/**
* Get Calculated Height on page
* @param pageNo page number
* @return Height
*/
public float getWidth (int pageNo)
{
int pageIndex = getPageIndex(pageNo);
if (pageIndex == 0)
return m_firstPage.width;
return m_nextPages.width;
} // getHeight
/*************************************************************************/
/**
* Get number of "real" pages.
* @return page count
*/
public int getPageCount()
{
return m_firstRowOnPage.size() * m_firstColumnOnPage.size();
} // getPageCount
/**
* Get zero based Page Index
* @param pageNo real page no
* @return page index
*/
protected int getPageIndex (int pageNo)
{
return pageNo - m_pageNoStart;
} // getPageIndex
/**
* Get "real" page Number
* @param pageIndex zero based page index
* @return page number
*/
private int getPageNo (int pageIndex)
{
return m_pageNoStart + pageIndex;
} // getPageNo
/*************************************************************************/
/**
* Get X - Page Index.
* Zero Based; Page No is the "real" page No
* <pre>
* The table is 3 pages wide, 2 pages high - index
* +-----+-----+-----+
* | 0.0 | 0.1 | 0.2 |
* +-----+-----+-----+
* | 1.0 | 1.1 | 1.2 |
* +-----+-----+-----+
* Page Index
* +-----+-----+-----+
* | 0 | 1 | 2 |
* +-----+-----+-----+
* | 3 | 4 | 5 |
* +-----+-----+-----+
* </pre>
* @param pageIndex zero based page index
* @return page index on X axis
*/
protected int getPageXIndex (int pageIndex)
{
int noXpages = m_firstColumnOnPage.size();
// int noYpages = m_firstRowOnPage.size();
int x = pageIndex % noXpages;
return x;
} // getPageXIndex
/**
* Get X - Page Count
* @return X page count
*/
protected int getPageXCount ()
{
return m_firstColumnOnPage.size();
} // getPageXCount
/**
* Get Y | Page Index.
* Zero Based; Page No is the "real" page No
* <pre>
* The table is 3 pages wide, 2 pages high - index
* +-----+-----+-----+
* | 0.0 | 0.1 | 0.2 |
* +-----+-----+-----+
* | 1.0 | 1.1 | 1.2 |
* +-----+-----+-----+
* Page Index
* +-----+-----+-----+
* | 0 | 1 | 2 |
* +-----+-----+-----+
* | 3 | 4 | 5 |
* +-----+-----+-----+
* </pre>
* @param pageIndex zero based page index
* @return page index on Y axis
*/
protected int getPageYIndex (int pageIndex)
{
int noXpages = m_firstColumnOnPage.size();
// int noYpages = m_firstRowOnPage.size();
int y = (pageIndex - (pageIndex % noXpages)) / noXpages;
return y;
} // getPageYIndex
/**
* Get Y | Page Count
* @return Y page count
*/
protected int getPageYCount ()
{
return m_firstRowOnPage.size();
} // getPageYCount
/*************************************************************************/
/**
* Get Drill Down value
* @param relativePoint relative Point
* @param pageNo page number
* @return if found Qyery or null
*/
public MQuery getDrillDown (Point relativePoint, int pageNo)
{
if (m_rowColDrillDown.size() == 0)
return null;
if (!getBounds(pageNo).contains(relativePoint))
return null;
int row = getRow (relativePoint.y, pageNo);
if (row == -1)
return null;
int col = getCol (relativePoint.x, pageNo);
if (col == -1)
return null;
Log.trace(Log.l5_DData, "TableElement.getDrillDown", "Row=" + row + ", Col=" + col + ", PageNo=" + pageNo);
//
NamePair pp = (NamePair)m_rowColDrillDown.get(new Point(row,col));
if (pp == null)
return null;
String columnName = m_columnHeader[col].getID();
String tableName = columnName;
int index = tableName.lastIndexOf("_ID");
if (index != -1)
tableName = tableName.substring(0, index);
Object code = pp.getID();
if (pp instanceof KeyNamePair)
code = new Integer(((KeyNamePair)pp).getKey());
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code, null, pp.toString());
return query;
} // getDrillDown
/**
* Get Drill Across value
* @param relativePoint relative Point
* @param pageNo page number
* @return if found Query or null
*/
public MQuery getDrillAcross (Point relativePoint, int pageNo)
{
if (!getBounds(pageNo).contains(relativePoint))
return null;
int row = getRow (relativePoint.y, pageNo);
if (row == -1)
return null;
Log.trace(Log.l5_DData, "TableElement.getDrillAcross", "Row=" + row + ", PageNo=" + pageNo);
//
if (m_pk[row] == null) // FunctionRows
return null;
return MQuery.getEqualQuery(m_pkColumnName, m_pk[row].getKey());
} // getDrillAcross
/**
* Get relative Bounds of Element.
* (entire page, not just used portion)
* @param pageNo pageNo
* @return bounds relative position on page
*/
public Rectangle getBounds(int pageNo)
{
int pageIndex = getPageIndex(pageNo);
int pageYindex = getPageYIndex(pageIndex);
if (pageYindex == 0)
return m_firstPage;
else
return m_nextPages;
} // getBounds
/**
* Get Row for yPos
* @param yPos y position (page relative)
* @param pageNo page number
* @return row index or -1
*/
private int getRow (int yPos, int pageNo)
{
int pageIndex = getPageIndex(pageNo);
int pageYindex = getPageYIndex(pageIndex);
//
int curY = (pageYindex == 0 ? m_firstPage.y : m_nextPages.y) + m_headerHeight;
if (yPos < curY)
return -1; // above
//
int firstRow = ((Integer)m_firstRowOnPage.get(pageYindex)).intValue();
int nextPageRow = m_data.length; // no of rows
if (pageYindex+1 < m_firstRowOnPage.size())
nextPageRow = ((Integer)m_firstRowOnPage.get(pageYindex+1)).intValue();
//
for (int row = firstRow; row < nextPageRow; row++)
{
int rowHeight = ((Float)m_rowHeights.get(row)).intValue(); // includes 2*Gaps+Line
if (yPos >= curY && yPos < (curY + rowHeight))
return row;
curY += rowHeight;
}
// below
return -1;
} // getRow
/**
* Get Column for xPos
* @param xPos x position (page relative)
* @param pageNo page number
* @return column index or -1
*/
private int getCol (int xPos, int pageNo)
{
int pageIndex = getPageIndex(pageNo);
int pageXindex = getPageXIndex(pageIndex);
//
int curX = pageXindex == 0 ? m_firstPage.x : m_nextPages.x;
if (xPos < curX)
return -1; // too left
int firstColumn = ((Integer)m_firstColumnOnPage.get(pageXindex)).intValue();
int nextPageColumn = m_columnHeader.length; // no of cols
if (pageXindex+1 < m_firstColumnOnPage.size())
nextPageColumn = ((Integer)m_firstColumnOnPage.get(pageXindex+1)).intValue();
// fixed volumns
int regularColumnStart = firstColumn;
for (int col = 0; col < m_repeatedColumns; col++)
{
int colWidth = ((Float)m_columnWidths.get(col)).intValue(); // includes 2*Gaps+Line
if (xPos >= curX && xPos < (curX + colWidth))
return col;
curX += colWidth;
if (regularColumnStart == col)
regularColumnStart++;
}
// regular columns
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -