
org.yaoqiang.graph.model.OrganizationGraphModel Maven / Gradle / Ivy
package org.yaoqiang.graph.model;
import org.yaoqiang.graph.util.Utils;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.model.mxICell;
/**
* OrganizationGraphModel
*
* @author Shi Yaoqiang([email protected])
*/
public class OrganizationGraphModel extends YGraphModel {
private static final long serialVersionUID = -1904599108588078619L;
protected String name;
public OrganizationGraphModel() {
super();
}
public String getOrganizationName() {
return ((mxCell) getCell("com")).getValue().toString();
}
public void setOrganizationName(String name) {
((mxCell) getCell("com")).setValue(name);
}
public void addSampleCells(String orgName) {
mxCell orgCell = new mxCell(orgName, new mxGeometry(28, 28, 200, 35), "organizationName");
orgCell.setId("com");
orgCell.setVertex(true);
orgCell.setConnectable(false);
add(getCell("_1"), orgCell, 0);
orgCell = Utils.generateOrganizationCell("organizationRoot", orgName);
orgCell.setId(orgName.toLowerCase());
orgCell.setGeometry(new mxGeometry(570, 90, 32, 32));
add(getCell("_1"), orgCell, 0);
orgCell = Utils.generateOrganizationCell("organizationalUnit", "Management");
orgCell.setId("management");
orgCell.setGeometry(new mxGeometry(570, 170, 32, 32));
add(getCell("_1"), orgCell, 0);
orgCell = Utils.generateOrganizationCell("organizationalUnit", "Accountancy");
orgCell.setId("accountancy");
orgCell.setGeometry(new mxGeometry(500, 260, 32, 32));
add(getCell("_1"), orgCell, 0);
orgCell = Utils.generateOrganizationCell("organizationalUnit", "Engineering");
orgCell.setId("engineering");
orgCell.setGeometry(new mxGeometry(570, 260, 32, 32));
add(getCell("_1"), orgCell, 0);
orgCell = Utils.generateOrganizationCell("organizationalUnit", "Sales");
orgCell.setId("sales");
orgCell.setGeometry(new mxGeometry(640, 260, 32, 32));
add(getCell("_1"), orgCell, 0);
orgCell = new mxCell(null, new mxGeometry(), "organizationFlow");
orgCell.setEdge(true);
orgCell.getGeometry().setRelative(true);
orgCell.setSource((mxICell) getCell(orgName.toLowerCase()));
orgCell.setTarget((mxICell) getCell("management"));
add(getCell("_1"), orgCell, 0);
orgCell = new mxCell(null, new mxGeometry(), "organizationFlow");
orgCell.setEdge(true);
orgCell.getGeometry().setRelative(true);
orgCell.setSource((mxICell) getCell("management"));
orgCell.setTarget((mxICell) getCell("accountancy"));
add(getCell("_1"), orgCell, 0);
orgCell = new mxCell(null, new mxGeometry(), "organizationFlow");
orgCell.setEdge(true);
orgCell.getGeometry().setRelative(true);
orgCell.setSource((mxICell) getCell("management"));
orgCell.setTarget((mxICell) getCell("engineering"));
add(getCell("_1"), orgCell, 0);
orgCell = new mxCell(null, new mxGeometry(), "organizationFlow");
orgCell.setEdge(true);
orgCell.getGeometry().setRelative(true);
orgCell.setSource((mxICell) getCell("management"));
orgCell.setTarget((mxICell) getCell("sales"));
add(getCell("_1"), orgCell, 0);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy