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

📄 orgline.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.service.services.views.orgchart;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JComponent;


/**
 * This class implements an organization chart vertical + horizontal line.
 * It should be on top of each son cell of the organization chart
 */
public class OrgLine extends JComponent
{
    /** Some space. */
    private static final int SPACE1 = 10;

    /** Some space. */
    private static final int SPACE2 = 30;

    /** Some space. */
    private static final int SPACE3 = 60;

    /** Kind of line. */
    private short position;

    /** Background color. */
    private Color backColor = null;

    /**
     * Creates a new OrgLine object.
     *
     * @param abackColor  Background color.
     */
    public OrgLine(final Color abackColor)
    {
        super();
        this.position = OrgChartPanel.VERTICAL;
        this.backColor = abackColor;
    }

    /**
     * Creates a new OrgLine object.
     *
     * @param aposition  Kind of line.
     * @param abackColor  Background color.
     */
    public OrgLine(final short aposition, final Color abackColor)
    {
        super();
        this.position = aposition;
        this.backColor = abackColor;
    }

    /**
     * Gets minimum size of the component.
     *
     * @return The minimum size according to the kind of line and the kind of
     *  orgchart.
     */
    public final Dimension getMinimumSize()
    {
        if (position != OrgChartPanel.VERTICAL)
        {
            if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
            {
                return new Dimension(SPACE1, SPACE2);
            }
            else
            {
                return new Dimension(SPACE2, SPACE2);
            }
        }
        else
        {
            if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
            {
                return new Dimension(SPACE1, SPACE3);
            }
            else
            {
                return new Dimension(SPACE3, SPACE3);
            }
        }
    }

    /**
     * Gets preferred size of the component, which is the minimum size.
     *
     * @return The preferred size.
     */
    public final Dimension getPreferredSize()
    {
        return getMinimumSize();
    }

    /**
     * Gets maximum size of the component, which is the minimum size.
     *
     * @return The maximum size.
     */
    public final Dimension getMaximumSize()
    {
        return getMinimumSize();
    }

    /**
     * Draws the component.
     *
     * @param g  Graphics on which to draw the component.
     */
    public final void paint(final Graphics g)
    {
        int w = getSize().width;
        int h = getSize().height;

        // background color
        if (backColor != null)
        {
            g.setColor(backColor);
            g.fillRect(0, 0, w, h);
        }

        // lines
        g.setColor(Color.black);

        if (!(position == OrgChartPanel.HORIZONTAL))
        {
            if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
            {
                g.drawLine(w / 2, 0, w / 2, h);
                g.drawLine((w / 2) - 1, 0, (w / 2) - 1, h);
            }
            else
            {
                g.drawLine(0, h / 2, w, h / 2);
                g.drawLine(0, (h / 2) - 1, w, (h / 2) - 1);
            }
        }
    }
}

⌨️ 快捷键说明

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