⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printview.java

📁 create the email in the server
💻 JAVA
字号:
/*
 * Created on 2005/01/30
 */

package za.co.halo.SecureCommunications.util;

import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.text.BoxView;
import javax.swing.text.Element;
import javax.swing.text.View;

//import za.co.iocom.util.Bug;

/**
 * This class is used to layout a printable item on actual pages.
 * 
 * @see HTMLPane
 * 
 * 
 * @bug This class asumes the children of the element fits onto a
 * page. If it doesn't, printing never terminates, always
 * trying the next page. Eventually heap space runs out.
 * 
 * TODO fix this
 * 
 * @author stolen from "Swing book" found on web :TODO find
 *         real author
 * @author (Edited) iocom
 */

public class PrintView extends BoxView
{
	private int m_firstOnPage = 0;// index of the first
	// view to be rendered
	// on the current page.

	private int m_lastOnPage = 0;// Index of the last
	// view to be rendered
	// on the current page.

	private int m_pageIndex = 0; // index of the current

	// page.

	public PrintView(Element elem, View root, int w, int h)
	{
		super(elem, Y_AXIS);
		setParent(root);
		setSize(w, h);
		layout(w, h);
	}

	public boolean paintPage(Graphics g, int hPage, int pageIndex)
	{
		//Bug.pr("PPP: getViewCount()" + getViewCount());
		//Bug.pr("pageIndex " + pageIndex + " m_pageIndex " + m_pageIndex);

		if (pageIndex > m_pageIndex)
		{
			m_firstOnPage = m_lastOnPage + 1;

			//Bug.pr("PPP2: getViewCount()" + getViewCount() + " m_firstOnPage " + m_firstOnPage
			//		+ " m_lastOnPage " + m_lastOnPage);

			if (m_firstOnPage >= getViewCount())
				return false;

			m_pageIndex = pageIndex;
		}

		int yMin = getOffset(Y_AXIS, m_firstOnPage);
		int yMax = yMin + hPage;
		Rectangle rc = new Rectangle();

		for (int k = m_firstOnPage; k < getViewCount(); k++)
		{
			rc.x = getOffset(X_AXIS, k);
			rc.y = getOffset(Y_AXIS, k);
			rc.width = getSpan(X_AXIS, k);
			rc.height = getSpan(Y_AXIS, k);
			if (rc.y + rc.height > yMax)
				break;
			m_lastOnPage = k;
			rc.y -= yMin;
			paintChild(g, rc, k);
		}
		return true;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -