📄 shapescontol.java
字号:
package connex.plugins.whiteboard;
import java.util.Vector;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ShapesContol {
private static ShapesContol instance = null;
private Vector<ShapeObj> shapes = new Vector<ShapeObj> ();
/**
* @directed
*/
private transient LocalListener local;
/**
* @directed
*/
private transient RemoteListener remote;
public ShapesContol() {
}
public void put(String key, ShapeObj shape) {
shapes.addElement(shape);
if (remote != null) {
remote.sendShape(key, shape);
}
}
public void putIfAbsent(String key, ShapeObj shape){
replace(key, shape);
if (remote != null) {
remote.sendShape(key, shape);
}
}
public void ShapeSelected(String key){
if (remote != null) {
remote.sendLock(key);
}
}
public void shapeMoved(String key, ShapeObj shape){
if (remote != null) {
remote.sendShape(key, shape);
}
}
public void shapeFilled(String key, ShapeObj shape){
shapeMoved(key,shape);
}
public void remotePut(String key, ShapeObj shape) {
shape.clearSelection();
this.replace(key, shape);
local.update();
}
public Vector getShapes() {
return (Vector) shapes.clone();
}
public boolean isEmpty() {
return shapes.isEmpty();
}
public int size() {
return shapes.size();
}
/**
* replace
*
* @param key String
* @param shape ShapeObj
*/
private synchronized void replace(String key, ShapeObj shape) {
int n = shapes.size();
for (int i = 0; i < n; i++) {
if (key.equals(shapes.elementAt(i).getID())) {
shapes.remove(i);
shapes.add(i, shape);
return;
}
}
shapes.addElement(shape);
}
/**
* containsKey
*
* @param key String
* @return boolean
*/
private boolean containsKey(String key) {
int n = shapes.size();
for (int i = 0; i < n; i++) {
if (key.equals(shapes.elementAt(i).getID())) {
return true;
}
}
return false;
}
public void remoteClear() {
shapes.removeAllElements();
local.update();
}
public void clear() {
shapes.removeAllElements();
if (remote != null) {
remote.sendClear();
}
}
public void close() {
shapes.removeAllElements();
}
public void remove(String key) {
int n = shapes.size();
for (int i = 0; i < n; i++) {
if (key.equals(shapes.elementAt(i).getID())) {
shapes.removeElementAt(i);
if (remote != null) {
remote.sendRemove(key);
}
break;
}
}
}
public void remoteRemove(String key) {
int n = shapes.size();
for (int i = 0; i < n; i++) {
if (key.equals(shapes.elementAt(i).getID())) {
shapes.removeElementAt(i);
break;
}
}
local.update();
}
public void lock(String key,String locker){
ShapeObj obj;
int n = shapes.size();
for (int i = 0; i < n; i++) {
obj=shapes.elementAt(i);
if (key.equals(obj.getID())) {
obj.lock(locker);
break;
}
}
}
public static synchronized ShapesContol getInstance() {
if (instance == null) {
instance = new ShapesContol();
}
return instance;
}
public void setLocalListener(LocalListener local) {
this.local = local;
}
public void setRemoteListener(RemoteListener remote) {
this.remote = remote;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -