com.threerings.tudey.tools
Class EntryEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by com.threerings.tudey.tools.EntryEdit
All Implemented Interfaces:
Serializable, UndoableEdit

public class EntryEdit
extends AbstractUndoableEdit

Represents an edit to the scene's entries (and paint).

See Also:
Serialized Form

Field Summary
protected  Map<Object,TudeySceneModel.Entry> _added
          The entries added in this edit.
protected  int _id
          The edit id, which determines which edits we can merge.
protected  int _layer
          The layer to which this edit applies.
protected  Map<Coord,TudeySceneModel.Paint> _paint
          The paint set or cleared in this edit.
protected  Map<Object,TudeySceneModel.Entry> _removed
          The entries removed in this edit.
protected  TudeySceneModel _scene
          The affected scene.
protected  Map<Object,TudeySceneModel.Entry> _updated
          The entries updated in this edit.
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
EntryEdit(TudeySceneModel scene, int id, int layer, Rectangle region, TudeySceneModel.Paint paint)
          Creates and applies a new paint edit.
EntryEdit(TudeySceneModel scene, int id, int layer, TudeySceneModel.Entry[] add, TudeySceneModel.Entry[] update, Object[] remove)
          Creates and applies a new entry edit.
 
Method Summary
 boolean addEdit(UndoableEdit edit)
           
 void redo()
           
protected  void swap(Map<Object,TudeySceneModel.Entry> removed, Map<Object,TudeySceneModel.Entry> added)
          Performs the actual undo or redo operation.
 void undo()
           
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
canRedo, canUndo, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_scene

protected TudeySceneModel _scene
The affected scene.


_id

protected int _id
The edit id, which determines which edits we can merge.


_layer

protected int _layer
The layer to which this edit applies.


_added

protected Map<Object,TudeySceneModel.Entry> _added
The entries added in this edit.


_updated

protected Map<Object,TudeySceneModel.Entry> _updated
The entries updated in this edit.


_removed

protected Map<Object,TudeySceneModel.Entry> _removed
The entries removed in this edit.


_paint

protected Map<Coord,TudeySceneModel.Paint> _paint
The paint set or cleared in this edit.

Constructor Detail

EntryEdit

public EntryEdit(TudeySceneModel scene,
                 int id,
                 int layer,
                 TudeySceneModel.Entry[] add,
                 TudeySceneModel.Entry[] update,
                 Object[] remove)
Creates and applies a new entry edit.


EntryEdit

public EntryEdit(TudeySceneModel scene,
                 int id,
                 int layer,
                 Rectangle region,
                 TudeySceneModel.Paint paint)
Creates and applies a new paint edit.

Method Detail

addEdit

public boolean addEdit(UndoableEdit edit)
Specified by:
addEdit in interface UndoableEdit
Overrides:
addEdit in class AbstractUndoableEdit

undo

public void undo()
          throws CannotUndoException
Specified by:
undo in interface UndoableEdit
Overrides:
undo in class AbstractUndoableEdit
Throws:
CannotUndoException

redo

public void redo()
          throws CannotRedoException
Specified by:
redo in interface UndoableEdit
Overrides:
redo in class AbstractUndoableEdit
Throws:
CannotRedoException

swap

protected void swap(Map<Object,TudeySceneModel.Entry> removed,
                    Map<Object,TudeySceneModel.Entry> added)
Performs the actual undo or redo operation.

Parameters:
removed - the map containing the entries to add.
added - the map containing the entries to remove.