📄 processpart.java
字号:
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Point;
import java.util.Vector;
import javax.swing.JComponent;
import org.cip4.jdflib.core.JDFElement;
import org.cip4.jdflib.node.JDFNode;
/*
* FooProcessPart.java
* @author SvenoniusI
*/
public class ProcessPart extends JComponent
{
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 5703455772001305819L;
public int width;
public int height;
private String name;
private JDFElement elem;
private JDFElement link;
private FontMetrics fm;
private Color gColor;
private String[] gString;
private Vector vInRes = new Vector();
private Vector vOutRes = new Vector();
private Vector vAllRes = new Vector();
private int xPos;
private int yPos;
private int yResIn;
private int yResOut;
private boolean sharedInput;
public ProcessPart(JDFElement elem, String name)
{
this.elem = elem;
this.name = name;
}
public void setGfxParams(FontMetrics fm, int xPos, int yPos)
{
this.xPos = xPos;
this.yPos = yPos;
this.fm = fm;
if(elem instanceof JDFNode)
{
height = 75;
if (name.equals("ParentPart"))
gColor = new Color(215, 245, 255);
else
gColor = new Color(180, 230, 250);
JDFNode node = (JDFNode) elem;
if (node.isCombined())
{
String[] tmp = { elem.getNodeName() + " " + elem.getAttribute("Type"),
elem.getAttribute("Types"),
elem.getID(),
elem.getAttribute("Status"),
elem.getDescriptiveName()};
gString = tmp;
}
else
{
String[] tmp = { elem.getNodeName() + " " + elem.getAttribute("Type"),
elem.getID(),
elem.getAttribute("Status"),
elem.getDescriptiveName()};
gString = tmp;
}
width = setPartWidth(gString);
}
else if (name.equals("ResPart"))
{
height = 45;
gColor = new Color(200, 250, 200);
String[] tmp = { elem.getNodeName(),
elem.getID() };
gString = tmp;
width = setPartWidth(gString);
}
else //if (JDFElement.isResourceStatic(elem))
{
height = 60;
gColor = new Color(200, 250, 200);
String[] tmp = { elem.getNodeName(),
elem.getID(),
elem.getAttribute("Status", "", "") };
gString = tmp;
width = setPartWidth(gString);
}
width += 30;
}
private int setPartWidth(String[] s)
{
int w = 0;
for (int i = 0; i < s.length; i++)
{
w = w < fm.stringWidth(s[i]) ? fm.stringWidth(s[i]) : w;
}
return w;
}
public String getName()
{
return this.name;
}
public JDFElement getElem()
{
return this.elem;
}
public JDFElement getLink()
{
return this.link;
}
public void setLink(JDFElement link)
{
this.link = link;
}
public Point getInPoint()
{
final Point p = new Point(xPos + this.width, yPos + this.height / 2);
return p;
}
public Point getOutPoint()
{
final Point p = new Point(xPos, yPos + this.height / 2);
return p;
}
public int getyResIn()
{
return this.yResIn;
}
public void setyResIn(int yResIn)
{
this.yResIn = yResIn;
}
public int getyResOut()
{
return this.yResOut;
}
public void setyResOut(int yResOut)
{
this.yResOut = yResOut;
}
/*public int getXPosition()
{
return this.xPosition;
}*/
public Vector getvAllRes()
{
/*Vector vAllRes = new Vector();
for (int i = 0; i < vInRes.size(); i ++)
{
vAllRes.add(vInRes.get(i));
}
for (int i = 0; i < vOutRes.size(); i ++)
{
vAllRes.add(vOutRes.get(i));
}
return vAllRes;*/
return this.vAllRes;
}
public void addTovAllRes(ProcessPart pp)
{
this.vAllRes.add(pp);
}
public boolean hasRes(ProcessPart pp)
{
return this.vInRes.contains(pp) || this.vOutRes.contains(pp);
}
public Vector getvInRes()
{
return this.vInRes;
}
/*public boolean hasInRes(ProcessPart pp)
{
return this.vInRes.contains(pp);
}*/
public void addTovInRes(ProcessPart pp)
{
this.vInRes.add(pp);
}
public Vector getvOutRes()
{
return this.vOutRes;
}
/*public boolean hasOutRes(ProcessPart pp)
{
return this.vOutRes.contains(pp);
}*/
public void addTovOutRes(ProcessPart pp)
{
this.vOutRes.add(pp);
}
public void setSharedInput(boolean sharedInput)
{
this.sharedInput = sharedInput;
}
public boolean hasSharedInput()
{
return this.sharedInput;
}
public Color getgColor()
{
return this.gColor;
}
public String[] getgString()
{
return this.gString;
}
public int getxPos()
{
return this.xPos;
}
public int getyPos()
{
return this.yPos;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -