📄 subprocessview.java
字号:
package org.jgpd.jgraph;
import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import org.jgraph.JGraph;
import org.jgraph.graph.CellMapper;
import org.jgraph.graph.CellViewRenderer;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.VertexRenderer;
import org.jgraph.graph.VertexView;
public class SubProcessView
extends VertexView {
final static BasicStroke stroke=new BasicStroke(4.0f);
public static int default_width = 100;
public static int default_height = 60;
public static SubProcessRenderer renderer = new SubProcessRenderer();
public SubProcessView(Object cell, JGraph graph, CellMapper cm) {
super(cell, graph, cm);
}
/**
* Returns the intersection of the bounding rectangle and the
* straight line between the source and the specified point p.
* The specified point is expected not to intersect the bounds.
*/
public static int getArcSize(int width, int height) {
int arcSize;
// The arc width of a activity rectangle is 1/5th of the larger
// of the two of the dimensions passed in, but at most 1/2
// of the smaller of the two. 1/5 because it looks nice and 1/2
// so the arc can complete in the given dimension
if (width <= height) {
arcSize = height / 5;
if (arcSize > (width / 2)) {
arcSize = width / 2;
}
}
else {
arcSize = width / 5;
if (arcSize > (height / 2)) {
arcSize = height / 2;
}
}
return arcSize;
}
public CellViewRenderer getRenderer() {
return renderer;
}
public static class SubProcessRenderer
extends VertexRenderer {
public void paint(Graphics g) {
int b = borderWidth;
Graphics2D g2 = (Graphics2D) g;
Dimension d = getSize();
boolean tmp = selected;
int roundRectArc = SubProcessView.getArcSize(d.width - b,
d.height - b);
if (super.isOpaque()) {
g2.setColor(super.getBackground());
g2.fillRoundRect(b - 1,
b - 1,
d.width - b,
d.height - b,
roundRectArc,
roundRectArc);
//画小方框
g2.drawRect((d.width+b)/2-15,d.height+b-30,30,30);
//画"+"号
g2.setStroke(stroke);
g2.drawLine((d.width+b)/2-10,d.height+b-15,(d.width+b)/2+10,d.height+b-15);
g2.drawLine((d.width+b)/2,d.height+b-25,(d.width+b)/2,d.height+b-5);
}
try {
setBorder(null);
setOpaque(false);
selected = false;
super.paint(g);
}
finally {
selected = tmp;
}
if (bordercolor != null) {
g2.setColor(bordercolor);
g2.setStroke(new BasicStroke(b));
g2.drawRoundRect(b - 1,
b - 1,
d.width - b,
d.height - b,
roundRectArc,
roundRectArc);
//画小方框
g2.drawRect((d.width+b)/2-15,d.height+b-30,30,30);
//画"+"号
g2.setStroke(stroke);
g2.drawLine((d.width+b)/2-10,d.height+b-15,(d.width+b)/2+10,d.height+b-15);
g2.drawLine((d.width+b)/2,d.height+b-25,(d.width+b)/2,d.height+b-5);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g2.setColor(graph.getBackground());
g2.drawRoundRect(b - 1,
b - 1,
d.width - b,
d.height - b,
roundRectArc,
roundRectArc);
//画小方框
g2.drawRect((d.width+b)/2-15,d.height+b-30,30,30);
//画"+"号
g2.setStroke(stroke);
g2.drawLine((d.width+b)/2-10,d.height+b-15,(d.width+b)/2+10,d.height+b-15);
g2.drawLine((d.width+b)/2,d.height+b-25,(d.width+b)/2,d.height+b-5);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -