Sketcher2 source code
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.0 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.BitmapUndoData;
import com.jotuntech.sketcher.common.UndoEntry;
import com.jotuntech.sketcher.common.User;
public class UndoDataCommand implements Command {
byte[] data;
public int perform(Client client, User user) {
if(user == null) {
return Connection.SEND_NONE;
}
if(user.isViewer()) {
return Connection.SEND_NONE;
}
Deque<UndoEntry> undoDeque = user.getUndoDeque();
if(undoDeque.size() == 0) {
return Connection.SEND_NONE;
}
BitmapUndoData bud = (BitmapUndoData) undoDeque.getLast().getUndoData();
bud.decode(data);
return Connection.SEND_NONE;
}
public void decode(ByteBuffer in) {
data = new byte[in.remaining()];
in.get(data);
}
public void encode(ByteBuffer out) {
out.put(data);
}
}