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.
45 lines
1.1 KiB
45 lines
1.1 KiB
package com.jotuntech.sketcher.client.command;
|
|
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Deque;
|
|
|
|
import com.jotuntech.sketcher.client.Client;
|
|
import com.jotuntech.sketcher.client.Command;
|
|
import com.jotuntech.sketcher.client.Connection;
|
|
import com.jotuntech.sketcher.common.UndoEntry;
|
|
import com.jotuntech.sketcher.common.User;
|
|
|
|
public class MergeCommand implements Command {
|
|
public int perform(Client client, User user) {
|
|
if(user == null || user.getLayer() == null) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
if(user.isViewer()) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
if(user.getPhantomLayer().isEmpty()) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
UndoEntry undoEntry = new UndoEntry();
|
|
undoEntry.setLayer(user.getLayer());
|
|
undoEntry.setUndoData(user.getLayer().merge(user.getPhantomLayer()));
|
|
Deque<UndoEntry> undoDeque = user.getUndoDeque();
|
|
undoDeque.addFirst(undoEntry);
|
|
while(undoDeque.size() > 10) {
|
|
undoDeque.removeLast();
|
|
}
|
|
|
|
return Connection.SEND_OTHERS;
|
|
}
|
|
|
|
public void decode(ByteBuffer in) {
|
|
|
|
}
|
|
|
|
public void encode(ByteBuffer out) {
|
|
|
|
}
|
|
}
|
|
|