You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
2.6 KiB
136 lines
2.6 KiB
package com.jotuntech.sketcher.common;
|
|
|
|
import java.awt.Rectangle;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.Deque;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedList;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
* User context specific data
|
|
*
|
|
* @author Thor Harald Johansen
|
|
*/
|
|
public class User implements Comparable<User> {
|
|
/** User's name */
|
|
private String name;
|
|
|
|
/** Viewer status */
|
|
private boolean viewer;
|
|
|
|
/** Current layer */
|
|
private WeakReference<Layer> layer = new WeakReference<Layer>(null);
|
|
|
|
/** Phantom layer */
|
|
private Layer phantomLayer;
|
|
|
|
/** Current brush */
|
|
private Brush brush;
|
|
|
|
/** Current color */
|
|
private int color = 0x000000;
|
|
|
|
/** Current cursor */
|
|
private Input cursor = new Input(0f, 0f);
|
|
|
|
/** Undo deque */
|
|
private Deque<UndoEntry> undoDeque = new LinkedList<UndoEntry>();
|
|
|
|
/** Tag position */
|
|
private Rectangle tag = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE);
|
|
|
|
/** Attributes */
|
|
private Map<String, Object> attributes = new HashMap<String, Object>();
|
|
|
|
|
|
public User() {
|
|
this.phantomLayer = new BitmapLayer("Phantom Layer");
|
|
}
|
|
|
|
public User(String name) {
|
|
this.name = name;
|
|
this.phantomLayer = new BitmapLayer(name + " Phantom Layer");
|
|
}
|
|
|
|
public int compareTo(User o) {
|
|
return getName().compareTo(((User)o).getName());
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setLayer(Layer layer) {
|
|
this.layer = new WeakReference<Layer>(layer);
|
|
}
|
|
|
|
public Layer getLayer() {
|
|
return layer.get();
|
|
}
|
|
|
|
public void setBrush(Brush brush) {
|
|
this.brush = brush;
|
|
}
|
|
|
|
public Brush getBrush() {
|
|
return brush;
|
|
}
|
|
|
|
public void setColor(int color) {
|
|
this.color = color;
|
|
}
|
|
|
|
public int getColor() {
|
|
return color;
|
|
}
|
|
|
|
public void setCursor(Input cursor) {
|
|
this.cursor = cursor;
|
|
}
|
|
|
|
public Input getCursor() {
|
|
return cursor;
|
|
}
|
|
|
|
public void setTag(Rectangle tag) {
|
|
this.tag = tag;
|
|
}
|
|
|
|
public Rectangle getTag() {
|
|
return tag;
|
|
}
|
|
|
|
public void setPhantomLayer(Layer phantomLayer) {
|
|
this.phantomLayer = phantomLayer;
|
|
}
|
|
|
|
public Layer getPhantomLayer() {
|
|
return phantomLayer;
|
|
}
|
|
|
|
public void setAttribute(String key, Object value) {
|
|
attributes.put(key, value);
|
|
}
|
|
|
|
public Object getAttribute(String key) {
|
|
return attributes.get(key);
|
|
}
|
|
|
|
public Deque<UndoEntry> getUndoDeque() {
|
|
return undoDeque;
|
|
}
|
|
|
|
public void setViewer(boolean viewer) {
|
|
this.viewer = viewer;
|
|
}
|
|
|
|
public boolean isViewer() {
|
|
return viewer;
|
|
}
|
|
}
|
|
|