📄 xjpanel2.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.Graphics;
import javax.swing.JPanel;
import javax.swing.tree.DefaultMutableTreeNode;
/**
*
* Panel representing a cell in "condensed" mode.
*/
public class XJPanel2 extends JPanel
{
/** Associated node. */
private DefaultMutableTreeNode node;
/** Parent node. */
private DefaultMutableTreeNode parent;
/** Space. */
private final int dh = 5;
/**
* Creates a new XJPanel2 object.
*
* @param anode Node associated with the cell.
*/
public XJPanel2(final DefaultMutableTreeNode anode)
{
this.node = anode;
this.parent = (DefaultMutableTreeNode) node.getParent();
}
/**
* Draws the component.
*
* @param g Graphics on which to draw.
*/
public final void paint(final Graphics g)
{
super.paint(g);
if (parent == null)
{
return;
}
if (parent.getChildCount() > 1)
{
if (parent.getFirstChild() == node)
{
if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
{
g.drawLine(getWidth() / 2, 0, getWidth(), 0);
g.drawLine(getWidth() / 2, 1, getWidth(), 1);
}
else
{
g.drawLine(0, (getHeight() / 2) + dh, 0, getHeight());
g.drawLine(1, (getHeight() / 2) + dh, 1, getHeight());
}
}
else if (parent.getLastChild() == node)
{
if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
{
g.drawLine(0, 0, getWidth() / 2, 0);
g.drawLine(0, 1, getWidth() / 2, 1);
}
else
{
g.drawLine(0, 0, 0, (getHeight() / 2) + dh);
g.drawLine(1, 0, 1, (getHeight() / 2) + dh);
}
}
else
{
if (OrgChartPanel.getDirection() == OrgChartPanel.HORIZONTAL)
{
g.drawLine(0, 0, getWidth(), 0);
g.drawLine(0, 1, getWidth(), 1);
}
else
{
g.drawLine(0, 0, 0, getHeight());
g.drawLine(1, 0, 1, getHeight());
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -