home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / tvbrowser / TvBrowser_1.0.exe / plugins / PrintPlugin.jar / printplugin / ColumnHeader.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-09-19  |  1.6 KB  |  41 lines

  1. package printplugin;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Font;
  5. import java.awt.FontMetrics;
  6. import java.awt.Graphics;
  7. import javax.swing.Icon;
  8.  
  9. public class ColumnHeader implements Icon {
  10.    private static Font mFont = new Font("Dialog", 1, 24);
  11.    private int mWidth;
  12.    private int mHeight;
  13.    private String mTitle;
  14.    private double mZoom;
  15.  
  16.    public ColumnHeader(String title, int width, int height, double zoom) {
  17.       this.mTitle = title;
  18.       this.mWidth = width;
  19.       this.mHeight = height;
  20.       this.mZoom = zoom;
  21.    }
  22.  
  23.    public int getIconHeight() {
  24.       return this.mHeight;
  25.    }
  26.  
  27.    public int getIconWidth() {
  28.       return this.mHeight;
  29.    }
  30.  
  31.    public void paintIcon(Component comp, Graphics g, int x, int y) {
  32.       g.translate(x, y);
  33.       FontMetrics metrics = g.getFontMetrics(mFont);
  34.       int width = metrics.stringWidth(this.mTitle);
  35.       g.setFont(mFont);
  36.       g.drawRect(0, 0, this.mWidth, this.mHeight);
  37.       g.drawString(this.mTitle, (this.mWidth - width) / 2, mFont.getSize());
  38.       g.translate(-x, -y);
  39.    }
  40. }
  41.