📄 documentmodel.java.svn-base
字号:
package collector.gui.model;
import java.util.*;
import javax.swing.text.*;
import collector.gui.method.*;
public class DocumentModel
extends DefaultStyledDocument {
/** Creates a new instance of DocumentModel */
public DocumentModel() {}
public void appendElement(String m_pString) {
try {
//m_StayElementCollection.add(m_pString + "\n");
if (!m_RefeshTag) {
return;
}
int m_DocLen = this.getLength();
if (m_DocLen >= this.m_MaxElementCounter * 80) {
int m_RemoveLen = m_DocLen - this.m_MaxElementCounter * 80;
try {
this.remove(0, m_RemoveLen);
}
catch (BadLocationException m_BadLocationException) {
m_BadLocationException.printStackTrace();
return;
}
}
m_DocLen = this.getLength();
String m_String = m_pString + "\n";
insertString(m_DocLen, m_String, null);
/* Object [] m_StayObjects = m_StayElementCollection.toArray();
for(int i=m_StayObjects.length-1; i>=0 ; i--)
{
String element=m_StayObjects[i].toString();
insertString(m_DocLen,element,null);
}
m_StayElementCollection.clear();
*/
}
catch (Exception e) {
FrontGuiDefine.SystemPrintln("Error: " + e);
}
m_DataChanged = true;
}
public boolean getRefreshTag() {
return m_RefeshTag;
}
public void setRefreshTag(boolean m_RefeshTag) {
this.m_RefeshTag = m_RefeshTag;
}
public int clear() {
try {
this.remove(0, this.getLength());
m_StayElementCollection.clear();
}
catch (Exception m_Exception) {
FrontGuiDefine.SystemPrintln("Error at clear buffer。。。");
m_Exception.printStackTrace();
return -1;
}
return 1;
}
public boolean getDataChanged() {
return m_DataChanged;
}
public void setDataChanged(boolean m_DataChanged) {
this.m_DataChanged = m_DataChanged;
}
protected int m_MaxElementCounter = 1000;
protected boolean m_RefeshTag = true;
protected boolean m_DataChanged = false;
protected Collection m_EementCollection = new ArrayList();
protected Collection m_StayElementCollection = new ArrayList();
public static void main(String args[]) {
DocumentModel dm = new DocumentModel();
String text = new String();
for (int i = 0; i < 120; i++) {
text = "Element#" + i;
dm.appendElement(text);
}
dm.setRefreshTag(false);
for (int i = 200; i < 320; i++) {
text = "Element#" + i;
dm.appendElement(text);
}
try {
Thread.sleep(5000);
}
catch (Exception e) {
FrontGuiDefine.SystemPrintln("Thread interrupted at main:" + e);
}
;
dm.setRefreshTag(true);
text = "Element#END";
dm.appendElement(text);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -