📄 diagram.java
字号:
/*
* Created on 2005-1-24
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.example.model;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhanghao
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Diagram extends Element {
final public static String PROP_LOCATION = "LOCATION";
final public static String PROP_NAME = "NAME";
final public static String PROP_VISIBLE = "VISIBLE";
final public static String PROP_INPUTS = "INPUTS";
final public static String PROP_OUTPUTS = "OUTPUTS";
public static String PROP_NODE = "NODE";
protected List nodes = new ArrayList();
public void addNode(Node node) {
nodes.add(node);
fireStructureChange(PROP_NODE, nodes);
}
public void removeNode(Node node) {
nodes.remove(node);
fireStructureChange(PROP_NODE, nodes);
}
public List getNodes() {
return nodes;
}
public InputStream getAsStream() throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(os);
out.writeObject(this);
out.close();
InputStream istream = new ByteArrayInputStream(os.toByteArray());
os.close();
return istream;
}
public static Diagram makeFromStream(InputStream istream) throws IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(istream);
Diagram diagram = (Diagram) ois.readObject();
ois.close();
return diagram;
}
//
protected List outputs = new ArrayList(5);
protected List inputs = new ArrayList(5);
public void addInput(Connection connection) {
this.inputs.add(connection);
fireStructureChange(PROP_INPUTS, connection);
}
public void addOutput(Connection connection) {
this.outputs.add(connection);
fireStructureChange(PROP_OUTPUTS, connection);
}
public List getIncomingConnections() {
return this.inputs;
}
public List getOutgoingConnections() {
return this.outputs;
}
public void removeInput(Connection connection) {
this.inputs.remove(connection);
fireStructureChange(PROP_INPUTS, connection);
}
public void removeOutput(Connection connection) {
this.outputs.remove(connection);
fireStructureChange(PROP_OUTPUTS, connection);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -