zpen.java

来自「用Java写的报表.功能如下: 0.内建网络打印,网络预览功能! 1.文件操作。」· Java 代码 · 共 140 行

JAVA
140
字号
/*
 * Copyright 2002 EZCell , Inc. All rights reserved.
 * Version  1.0.
 * Author   W.John
 */
package ezcell;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;


/**
 * DOCUMENT ME!
 *
 * @version 1.00
 * @author W.John
 */
public class ZPen implements Serializable, Cloneable {
    /**
     * put your documentation comment here
     * @param zorder
     */
    static float[] dash = { 5, 1 };
    private Color color;
    private int width;
    private int zorder;

    /**
     * put your documentation comment here
     */
    public ZPen() {
    }

    /**
     * put your documentation comment here
     * @param     int width
     * @param     Color color
     */
    public ZPen(int width, Color color) {
        this.color = color;
        this.width = width;
    }

    /**
     * put your documentation comment here
     * @param color
     */
    public void setColor(Color color) {
        this.color = color;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public Color getColor() {
        return new Color(color.getRGB());
    }

    /**
     * put your documentation comment here
     * @param width
     */
    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getWidth() {
        return width;
    }

    /**
     *
     * @param zorder
     */
    public void setZorder(int zorder) {
        this.zorder = zorder;
    }

    /**
     * put your documentation comment here
     * @return
     */
    public int getZorder() {
        return zorder;
    }

    /**
     *
     * @return
     */
    public Object clone() {
        ZPen pen = null;

        try {
            pen = (ZPen) super.clone();
            pen.color = new Color(color.getRGB());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }

        return pen;
    }

    /**
     *
     * @param g2
     */
    public void paint(Graphics2D g2) {
        g2.setColor(color);
        g2.setStroke(new BasicStroke(width)); //,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER,1,dash,0));
    }

    /**
     * put your documentation comment here
     * @param ois
     * @exception ClassNotFoundException, IOException
     */
    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
        ois.defaultReadObject();
    }

    /**
     * put your documentation comment here
     * @param oos
     * @exception IOException
     */
    private void writeObject(ObjectOutputStream oos) throws IOException {
        oos.defaultWriteObject();
    }
}

⌨️ 快捷键说明

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