📄 tableelement.java
字号:
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 layout page number
* @return Height
*/
public float getHeight (int pageNo)
{
int pageIndex = getPageIndex(pageNo);
int pageYindex = getPageYIndex(pageIndex);
log.fine("Page=" + pageNo + " - PageIndex=" + pageIndex
+ ", PageYindex=" + pageYindex);
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.fine("Page=" + 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 within Layout
* @param pageNo real page no
* @return page index
*/
protected int getPageIndex (int pageNo)
{
int index = pageNo - m_pageNoStart;
if (index < 0)
log.log(Level.SEVERE, "index=" + index, new Exception());
return index;
} // getPageIndex
/**
* Get "real" page Number within Layout
* @param pageIndex zero based page index
* @return page number
*/
private int getPageNo (int pageIndex)
{
return pageIndex + m_pageNoStart;
} // 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.fine("Row=" + row + ", Col=" + col + ", PageNo=" + pageNo);
//
NamePair pp = (NamePair)m_rowColDrillDown.get(new Point(row,col));
if (pp == null)
return null;
String columnName = MQuery.getZoomColumnName(m_columnHeader[col].getID());
String tableName = MQuery.getZoomTableName(columnName);
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.fine("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
for (int col = regularColumnStart; col < nextPageColumn; col++)
{
int colWidth = ((Float)m_columnWidths.get(col)).intValue(); // includes 2*Gaps+Line
if (xPos >= curX && xPos < (curX + colWidth))
return col;
curX += colWidth;
} // for all columns
// too right
return -1;
} // getCol
/**************************************************************************
* Paint/Print.
*
* @param g2D Graphics
* @param pageNo page number for multi page support (0 = header/footer)
* @param pageStart top left Location of page
* @param ctx context
* @param isView true if online view (IDs are links)
*/
public void paint (Graphics2D g2D, int pageNo, Point2D pageStart, Properties ctx, boolean isView)
{
int pageIndex = getPageIndex(pageNo);
int pageXindex = getPageXIndex(pageIndex);
int pageYindex = getPageYIndex(pageIndex);
if (DEBUG_PRINT)
log.config("Page=" + pageNo + " [x=" + pageXindex + ", y=" + pageYindex + "]");
//
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();
//
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();
if (DEBUG_PRINT)
log.finest("Col=" + firstColumn + "-" + (nextPageColumn-1)
+ ", Row=" + firstRow + "-" + (nextPageRow-1));
// Top Left
int startX = (int)pageStart.getX();
int startY = (int)pageStart.getY();
// Table Start
startX += pageXindex == 0 ? m_firstPage.x : m_nextPages.x;
startY += pageYindex == 0 ? m_firstPage.y : m_nextPages.y;
if (DEBUG_PRINT)
log.finest("PageStart=" + pageStart + ", StartTable x=" + startX + ", y=" + startY);
// paint first fixed volumns
boolean firstColumnPrint = true;
int regularColumnStart = firstColumn;
for (int col = 0; col < m_repeatedColumns && col < m_columnWidths.size(); col++)
{
int colWidth = ((Float)m_columnWidths.get(col)).intValue(); // includes 2*Gaps+Line
if (colWidth != 0)
{
printColumn (g2D, col, startX, startY, firstColumnPrint, firstRow, nextPageRow, isView);
startX += colWidth;
firstColumnPrint = false;
}
if (regularColumnStart == col)
regularColumnStart++;
}
// paint columns
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -