📄 dsxmlreadwrite.java
字号:
String sframecolor = jds.getAttribute("framecolor").getValue();
String sID = jds.getAttribute("ID").getValue();
int fillcolor_rgb = Integer.parseInt(sfillcolor);
int framecolor_rgb = Integer.parseInt(sframecolor);
Color fillcolor = new Color(fillcolor_rgb);
Color framecolor = new Color(framecolor_rgb);
//矩形
if (tag.equals("RectangleSpace")) {
jDSComponentface = new DSExtendRectangleSpace(jDSDesktopface);
}
//圆
else if (tag.equals("Elipse")) {
jDSComponentface = new DSExtendElipse(jDSDesktopface);
}
//菱形
else if (tag.equals("Diamond")) {
jDSComponentface = new DSExtendRectangleDiamond(jDSDesktopface);
}
//星
else if (tag.equals("Star")) {
jDSComponentface = new DSExtendRectangleStar(jDSDesktopface);
}
jDSComponentface.setCompinentRectangle(x, y, w, h);
jDSComponentface.setTextInfo(textinfo);
jDSComponentface.setFillColor(fillcolor);
jDSComponentface.setFrameColor(framecolor);
jDSComponentface.setComponentID(sID);
//add Desktop
jDSDesktopface.addJDSComponent(jDSComponentface);
}
else if (jds.getName().trim().equals("JDSLineface")) {
//jds
//start component
String sID_s=jds.getAttribute("start").getValue();
String sID_e=jds.getAttribute("end").getValue();
//
JDSComponentface JDSComponentfaceStart = null;
JDSComponentface JDSComponentfaceEnd = null;
JDSComponentface[] jDSComponentfaceAll = jDSDesktopface.
getJDSAllComponent();
for (int k = 0; k < jDSComponentfaceAll.length; k++) {
JDSComponentface JDSComponentfaceNew = jDSComponentfaceAll[k];
if(JDSComponentfaceNew.getComponentID().equals(sID_s))
{
JDSComponentfaceStart = JDSComponentfaceNew;
}
else if(JDSComponentfaceNew.getComponentID().equals(sID_e))
{
JDSComponentfaceEnd = JDSComponentfaceNew;
}
if (JDSComponentfaceEnd != null && JDSComponentfaceStart != null) {
break;
}
}
//create Line
JDSLineface jDSLineface = new DSExtendLineAspect();
jDSLineface.setJDSComponentStart(JDSComponentfaceStart);
jDSLineface.setJDSComponentEnd(JDSComponentfaceEnd);
//
JDSComponentfaceStart.addAssociator(jDSLineface);
JDSComponentfaceEnd.addAssociator(jDSLineface);
//add Desktop
jDSDesktopface.addJDSLineface(jDSLineface);
}
else if (jds.getName().trim().equals("TacheData")) {
String sID=jds.getAttribute("ID").getValue();
String sDescribe=jds.getAttribute("Describe").getValue();
sDescribe=sDescribe.replaceAll("@",newline);
String sStartdate=jds.getAttribute("Startdate").getValue();
String sEnddate=jds.getAttribute("Enddate").getValue();
String sPrincipal=jds.getAttribute("Principal").getValue();
SetupDataModel setupDataModel=new SetupDataModel();
setupDataModel.setDescribe(sDescribe);
setupDataModel.setStartdate(sStartdate);
setupDataModel.setEnddate(sEnddate);
Vector vector=new Vector();
if(sPrincipal.indexOf("@")>0)
{
String[] strPrincipals = sPrincipal.split("@");
if(strPrincipals!=null && strPrincipals.length>0)
{
for(int v=0;v<strPrincipals.length;v++)
{
vector.add(strPrincipals[v]);
}
}
}
else if(!sPrincipal.trim().equals(""))
{
vector.add(sPrincipal);
}
setupDataModel.setVector(vector);
hashMap.put(sID,setupDataModel);
}
}
//重置配置集合
jDSDesktopface.setHashMap(hashMap);
}
catch (Exception ioe) {
ioe.printStackTrace();
}
if (fileInputStream != null) {
try {
fileInputStream.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/**
*
* @param file File
* @param jDSExtendDesktopface JDSExtendDesktopface
* @todo Implement this drawsmart.itsv.framework.JDSXMLReadWriteface method
*/
public Object[] openElementUnRe(File file, JDSDesktopface jDSDesktopface) {
Object[] obj = new Object[2];
ArrayList arrayListUnComponent = new ArrayList();
ArrayList arrayListUnLine = new ArrayList();
obj[0] = arrayListUnComponent;
obj[1] = arrayListUnLine;
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
org.jdom.input.SAXBuilder sb = new org.jdom.input.SAXBuilder();
//创建文档
Document doc = sb.build(fileInputStream);
//获得这个文档得跟元素
Element el = doc.getRootElement();
java.util.List list = el.getChildren();
for (int i = 0; i < list.size(); i++) {
Element jds = (Element) list.get(i);
if (jds.getName().trim().equals("JDSComponentface")) {
JDSComponentface jDSComponentface = null;
//jds.getAttribute("x");
int x = Integer.parseInt(jds.getAttribute("x").getValue());
int y = Integer.parseInt(jds.getAttribute("y").getValue());
int w = Integer.parseInt(jds.getAttribute("w").getValue());
int h = Integer.parseInt(jds.getAttribute("h").getValue());
String tag = jds.getAttribute("style").getValue();
String textinfo = jds.getAttribute("textinfo").getValue();
String sfillcolor = jds.getAttribute("fillcolor").getValue();
String sframecolor = jds.getAttribute("framecolor").getValue();
String sID = jds.getAttribute("ID").getValue();
int fillcolor_rgb = Integer.parseInt(sfillcolor);
int framecolor_rgb = Integer.parseInt(sframecolor);
Color fillcolor = new Color(fillcolor_rgb);
Color framecolor = new Color(framecolor_rgb);
//矩形
if (tag.equals("RectangleSpace")) {
jDSComponentface = new DSExtendRectangleSpace(jDSDesktopface);
}
//圆
else if (tag.equals("Elipse")) {
jDSComponentface = new DSExtendElipse(jDSDesktopface);
}
jDSComponentface.setCompinentRectangle(x, y, w, h);
jDSComponentface.setTextInfo(textinfo);
jDSComponentface.setFillColor(fillcolor);
jDSComponentface.setFrameColor(framecolor);
jDSComponentface.setComponentID(sID);
//add Desktop
arrayListUnComponent.add(jDSComponentface);
}
else if (jds.getName().trim().equals("JDSLineface")) {
//jds
String sID_s = jds.getAttribute("start").getValue();
String sID_e = jds.getAttribute("end").getValue();
//
JDSComponentface JDSComponentfaceStart = null;
JDSComponentface JDSComponentfaceEnd = null;
JDSComponentface[] jDSComponentfaceAll = (JDSComponentface[])
arrayListUnComponent.toArray(new JDSComponentface[0]);
for (int k = 0; k < jDSComponentfaceAll.length; k++) {
JDSComponentface JDSComponentfaceNew = jDSComponentfaceAll[k];
if(JDSComponentfaceNew.getComponentID().equals(sID_s))
{
JDSComponentfaceStart = JDSComponentfaceNew;
}
else if(JDSComponentfaceNew.getComponentID().equals(sID_e))
{
JDSComponentfaceEnd = JDSComponentfaceNew;
}
if (JDSComponentfaceEnd != null && JDSComponentfaceStart != null) {
break;
}
}
//create Line
JDSLineface jDSLineface = new DSExtendLineAspect();
jDSLineface.setJDSComponentStart(JDSComponentfaceStart);
jDSLineface.setJDSComponentEnd(JDSComponentfaceEnd);
//
JDSComponentfaceStart.addAssociator(jDSLineface);
JDSComponentfaceEnd.addAssociator(jDSLineface);
//add Desktop
arrayListUnLine.add(jDSLineface);
}
}
}
catch (Exception ioe) {
ioe.printStackTrace();
}
if (fileInputStream != null) {
try {
fileInputStream.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
return obj;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -