home *** CD-ROM | disk | FTP | other *** search
- package printplugin;
-
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import javax.swing.Icon;
-
- public class ColumnHeader implements Icon {
- private static Font mFont = new Font("Dialog", 1, 24);
- private int mWidth;
- private int mHeight;
- private String mTitle;
- private double mZoom;
-
- public ColumnHeader(String title, int width, int height, double zoom) {
- this.mTitle = title;
- this.mWidth = width;
- this.mHeight = height;
- this.mZoom = zoom;
- }
-
- public int getIconHeight() {
- return this.mHeight;
- }
-
- public int getIconWidth() {
- return this.mHeight;
- }
-
- public void paintIcon(Component comp, Graphics g, int x, int y) {
- g.translate(x, y);
- FontMetrics metrics = g.getFontMetrics(mFont);
- int width = metrics.stringWidth(this.mTitle);
- g.setFont(mFont);
- g.drawRect(0, 0, this.mWidth, this.mHeight);
- g.drawString(this.mTitle, (this.mWidth - width) / 2, mFont.getSize());
- g.translate(-x, -y);
- }
- }
-