public final class SpenPaintingDoc extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
SpenPaintingDoc.HistoryListener
This listener interface provides callback methods for receiving history events.
The interface receives notifications when a new history event is committed by commitHistory(HistoryUpdateInfo) |
static class |
SpenPaintingDoc.HistoryUpdateInfo
This class contains the update history information.
|
static interface |
SpenPaintingDoc.LayerListener
This listener interface is called when the state of a layer is changed.
|
static interface |
SpenPaintingDoc.ObjectListener
This listener interface is called when the state of an object is changed.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
BACKGROUND_IMAGE_MODE_CENTER
Background image in the center.
|
static int |
BACKGROUND_IMAGE_MODE_FIT
Background image fits to PaintingDoc.
|
static int |
BACKGROUND_IMAGE_MODE_STRETCH
Background image stretched to fit the PaintingDoc.
|
static int |
BACKGROUND_IMAGE_MODE_TILE
Background image is tiled.
|
static int |
ORIENTATION_LANDSCAPE
Landscape orientation mode.
|
static int |
ORIENTATION_PORTRAIT
Portrait orientation mode.
|
| Constructor and Description |
|---|
SpenPaintingDoc(Context context,
int width,
int height,
String filePath)
Creates a SpenPaintingDoc instance with the specified file path.
If file is existed, then load the file. |
| Modifier and Type | Method and Description |
|---|---|
void |
appendLayer(int id)
Add a new layer with the specified ID.
The ID of the default layer for a PaintingDoc is 0. |
void |
appendObject(SpenObjectBase object)
Add the specified object to the current layer of the PaintingDoc document.
The add object action is recorded in the history stack. |
void |
attachToFile(String filePath)
Save all data and attach the saved data to given file.
|
void |
clearHistory()
Clear all the undo/redo history.
Even if undoable or redoable is cleared by this API, history listener is not called. |
void |
clearHistoryTag()
Clear the history tag.
|
void |
clearRedoHistory()
Clear all the redo commands.
|
void |
close()
Close the PaintingDoc.
|
void |
close(boolean removeCache)
Close the PaintingDoc.
|
SpenObjectBase |
createObject(int type)
Create a new instance of the specified object type.
|
void |
discard()
Discard the PaintingDoc instance.
|
boolean |
equals(Object o)
Compares the instance with the specified object and returns whether both is same or not.
|
ArrayList<SpenObjectBase> |
findObjectAtPosition(float x,
float y)
Find the list of objects at the specified location.
Objects within object containers cannot be found. |
ArrayList<SpenObjectBase> |
findObjectAtPosition(float x,
float y,
float threshold)
Find the list of objects in the range.
The range is the rectangle of ( x-threshold, y-threshold) to
(x+threshold, y+threshold). |
ArrayList<SpenObjectBase> |
findObjectInClosedCurve(PointF[] points)
Find the objects contained in the closed curves defined by the specified points.
The points connect the curve in order. If the curve does not intersect, this method connects the first point and the last point. If two points overlap, one of them is ignored and the next point is connected. Objects within object containers cannot be found. |
ArrayList<SpenObjectBase> |
findObjectInRect(RectF rectf,
boolean allAreas)
Find the objects in the rectangle with the specified points.
Objects within object containers cannot be found. |
SpenObjectBase |
findTopObjectAtPosition(float x,
float y)
Find the topmost object at the specified position.
Objects within object containers cannot be found. |
SpenObjectBase |
findTopObjectAtPosition(float x,
float y,
float threshold)
Find the topmost object in the range.
The range is the rectangle of ( x-threshold, y-threshold) to
(x+threshold, y+threshold). |
int |
getBackgroundColor()
Get the background color.
|
Bitmap |
getBackgroundImage()
Get the background image.
|
int |
getBackgroundImageMode()
Get the background image mode.
|
String |
getBackgroundImagePath()
Get the background image file path.
|
int |
getCurrentLayerId()
Get the ID of the current layer.
|
RectF |
getDrawnRectOfAllObject()
Get the total drawn rect of all the objects that fill the PaintingDoc.
If there are too many objects on the PaintingDoc, this method becomes slow. But if there is no change in the PaintingDoc, this method returns the result quickly because no recalculation is required. |
byte[] |
getExtraDataByteArray(String key)
Get the extra byte array data for the specified key.
|
int |
getExtraDataInt(String key)
Get the extra integer data for the specified key.
|
String |
getExtraDataString(String key)
Get the extra string data for the specified key.
|
String[] |
getExtraDataStringArray(String key)
Get the extra string array data for the specified key.
|
Bitmap |
getForegroundImage()
Get the foreground image bitmap
|
String |
getForegroundImagePath()
Get the foreground image file path.
|
int |
getHeight()
Get the PaintingDoc height.
|
String |
getId()
Get the PaintingDoc ID.
|
long |
getLastEditedTime()
Gets the time the PaintingDoc instance or its objects were last edited.
If nothing has changed, this method gets the time when the PaintingDoc was created. |
int |
getLayerCount()
Get the number of layers.
|
int |
getLayerIdByIndex(int index)
Get the ID of a layer with the specified index.
|
int |
getLayerIndex(int id)
Get the index of the specified layer.
|
String |
getLayerName(int id)
Get the name of the specified layer.
|
SpenObjectBase |
getObject(int index)
Get the object at the specified index in the current layer of the PaintingDoc document.
|
SpenObjectBase |
getObjectByRuntimeHandle(int runtimeHandle)
Get the object with the specified runtime handle in the current layer of the PaintingDoc document.
|
int |
getObjectCount(boolean includeInvisible)
Get the number of objects in the current layer of the PaintingDoc document.
|
int |
getObjectIndex(SpenObjectBase object)
Get the index of the specified object in the current layer of the PaintingDoc document.
|
ArrayList<SpenObjectBase> |
getObjectList()
Get the list of all objects in the current layer of the PaintingDoc document.
|
ArrayList<RectF> |
getObjectRectList()
Get the objects's rect list contained in PaintingDoc.
Objects within object containers cannot be found. |
int |
getOrientation()
Get the PaintingDoc orientation.
|
static void |
getSize(String filePath,
Integer width,
Integer height)
Get the width and height of the specified file.
|
int |
getUndoLimit()
Get the limit for the undo commands.
|
int |
getWidth()
Get the PaintingDoc width.
|
boolean |
hasExtraDataByteArray(String key)
Check if extra byte array data exists with the specified key.
|
boolean |
hasExtraDataInt(String key)
Check if extra integer data exists with the specified key.
|
boolean |
hasExtraDataString(String key)
Check if extra string data exists with the specified key.
|
boolean |
hasExtraDataStringArray(String key)
Check if extra string array data exists with the specified key.
|
int |
hashCode()
Gets an integer hash code for this object.
|
void |
insertLayer(int id,
int index)
Insert a new layer at the specified index with the specified ID.
The ID of the default layer for a PaintingDoc is 0. |
boolean |
isAllObjectsLoaded()
Check if the all objects are loaded.
|
boolean |
isChanged()
Check if the PaintingDoc, layers or objects have changed.
|
boolean |
isLayerChanged()
Check if there is a change in the layer.
|
boolean |
isLayerEventForwardEnabled(int id)
Check if event forwarding is enabled for the specified layer.
|
boolean |
isLayerVisible(int id)
Check if the specific layer is visible.
|
boolean |
isObjectContained(SpenObjectBase object)
Check if the specified object is contained in the current layer of the PaintingDoc document.
|
boolean |
isObjectLoaded()
Check if the objects are loaded.
|
boolean |
isRedoable()
Check if the action is redoable.
Check if the redo stack in the history manager is empty. If it is empty, there is no command to redo, and the method returns false. If it is not empty, it returns true. Always use this method before calling paintingDoc.redo(). |
boolean |
isReplayable()
Get replayable property
|
boolean |
isUndoable()
Check if the action is undoable.
Check if the undo stack in the history manager is empty. If it is empty, there is no command to undo, and this method returns false. If it is not empty, it returns true. Always call this method before calling paintingDoc.undo(). |
static boolean |
isValid(String filePath)
Check if the specified file is a valid SPP file.
|
void |
loadAllObjects()
Load all objects from all packed data.
When a PaintingDoc is first created, the isObjectLoaded() method returns true, but if you create a PaintingDoc with
an SPP file, the isObjectLoaded() method returns false. |
void |
loadObject()
Load objects from current packed data.
When a PaintingDoc is first created, the isObjectLoaded() method returns true, but if you create a PaintingDoc with
an SPP file, the isObjectLoaded() method returns false. |
void |
moveLayerIndex(int id,
int step)
Change the order of specific layer.
|
SpenPaintingDoc.HistoryUpdateInfo[] |
redo()
Redo the command and return the changed state information for updating the canvas.
After redo, the canvas view needs to be updated. |
SpenPaintingDoc.HistoryUpdateInfo[] |
redoAll()
Redo all the commands in the redo stack of the history manager and return the changed state information for
updating the canvas.
After redoAll, the canvas view needs to be updated. |
void |
removeAllObject()
Remove all the objects from the current layer and the selected object list of the PaintingDoc document.
The remove all objects action is not recorded in the history stack. |
void |
removeExtraDataByteArray(String key)
Remove the extra byte array data with the specified key.
|
void |
removeExtraDataInt(String key)
Remove the extra integer data with the specified key.
|
void |
removeExtraDataString(String key)
Remove the extra string data with the specified key.
|
void |
removeExtraDataStringArray(String key)
Remove the extra string array data with the specified key.
|
void |
removeLayer(int id)
Remove the specified layer.
You cannot remove all the layers. If a current layer is removed from the PaintingDoc, the layer in front of the layer becomes the current layer. For example, if the current layer is Layer 2 and it is removed, Layer 3 becomes the current layer. 0 - 1 - [2] - 3 - 4 (currnt layer is 2, removes 2 layer ) 0 - 1 - [3] - 4 (current layer is 3) If you call this method after calling the SpenPaintingView#setPaintingDoc(SpenPaintingDoc, boolean) method, this layer is
drawn on SpenPaintingView after SpenPaintingView#update(). |
void |
save(String filepath)
Save the PaintingDoc data to a file.
|
void |
setBackgroundColor(int color)
Set the specified background color.
|
void |
setBackgroundImage(String filePath)
Set the image from the specified file.
This method copies the original image file into the SPD file. |
void |
setBackgroundImageMode(int mode)
Set the specified background image mode.
|
void |
setCurrentLayer(int id)
Set the specified layer as the current layer.
Note : The selected object list is canceled. |
void |
setExtraDataByteArray(String key,
byte[] value)
Set the extra byte array data with the specified key.
|
void |
setExtraDataInt(String key,
int value)
Set the extra integer data with the specified key.
|
void |
setExtraDataString(String key,
String value)
Set the extra string data with the specified key.
|
void |
setExtraDataStringArray(String key,
String[] value)
Set the extra string array data with the specified key.
|
void |
setForegroundImage(Bitmap bitmap)
Set the image from the specified bitmap.
|
void |
setForegroundImage(String filePath)
Set the image from the specified file.
This method copies the original image file into the SPD file. |
void |
setHistoryListener(SpenPaintingDoc.HistoryListener listener)
Set the specified HistoryListener instance to receive history events.
|
void |
setHistoryTag()
Set a tag for the history manager.
To remove the tag, call clearTag or undoToTag. |
void |
setLayerEventForwardEnabled(int id,
boolean enable)
Enable or disable event forwarding for the specified layer.
Set to true to enable the layer to forward unprocessable events to the lower layer, set to false to disable layer event forwarding. |
void |
setLayerListener(SpenPaintingDoc.LayerListener listener)
Set the specified LayerListener instance to receive layer events.
|
void |
setLayerName(int id,
String name)
Set the specified name for the specified layer.
|
void |
setLayerVisibility(int id,
boolean visible)
Show or hide the specific layer.
|
void |
setObjectListener(SpenPaintingDoc.ObjectListener listener)
Set the specified ObjectListener instance to receive object events on the PaintingDoc.
|
void |
setReplayable(boolean replayable)
Set replayable property
|
void |
setUndoLimit(int undoLimit)
Set the limit for the number of undo commands in the undo stack.
|
void |
setVolatileBackgroundImage(Bitmap bitmap)
Set the specified image as the volatile background image.
This means the background image is not saved in the SPD file. |
void |
startHistoryGroup()
Create a history group.
A number of histories belong to a single history group, not merge into a single history. |
void |
stopHistoryGroup()
Close the history group.
|
SpenPaintingDoc.HistoryUpdateInfo[] |
undo()
Undo the command and return the previous state information for updating the canvas.
After undo, the canvas view needs to be updated. |
SpenPaintingDoc.HistoryUpdateInfo[] |
undoAll()
Undo all the commands in the undo stack of the history manager and return the previous state information for
updating the canvas.
After undoAll, the canvas view needs to be updated. |
SpenPaintingDoc.HistoryUpdateInfo[] |
undoToTag()
Undo the command to the tag and return the previous state information for updating the canvas.
After undoToTag, the redo stack is cleared and the canvas view needs to be updated. Note: If history tag out of the undo stack, it will be removed. |
void |
unloadObject()
Unload the objects in the PaintingDoc which is not being attached to view.
This method saves the objects and layers on the PaintingDoc in the cache directory and unloads them from memory. The unloaded objects cannot be used any more. When objects are unloaded, the methods for the objects trigger the loadObject method internally. You cannot use methods that receive an unloaded object instance as their parameter. The command history stack for the unloaded objects is cleared. |
public static final int ORIENTATION_PORTRAIT
getOrientation(),
Constant Field Valuespublic static final int ORIENTATION_LANDSCAPE
getOrientation(),
Constant Field Valuespublic static final int BACKGROUND_IMAGE_MODE_CENTER
setBackgroundImageMode(int),
getBackgroundImageMode(),
Constant Field Valuespublic static final int BACKGROUND_IMAGE_MODE_STRETCH
setBackgroundImageMode(int),
getBackgroundImageMode(),
Constant Field Valuespublic static final int BACKGROUND_IMAGE_MODE_FIT
setBackgroundImageMode(int),
getBackgroundImageMode(),
Constant Field Valuespublic static final int BACKGROUND_IMAGE_MODE_TILE
setBackgroundImageMode(int),
getBackgroundImageMode(),
Constant Field Valuespublic SpenPaintingDoc(Context context, int width, int height, String filePath) throws IOException
context - The Context for your application.width - The SpenPaintingDoc width in pixels.height - The SpenPaintingDoc height in pixels.filePath - The absolute path of the file.IOException - Thrown if the cache directory is not generated.public int getWidth()
public int getHeight()
public long getLastEditedTime()
public void appendObject(SpenObjectBase object)
object - The object that you want to add. The valid type of object is SpenObjectBase.TYPE_STROKE only.IllegalStateException - Thrown if the object has already been added.IllegalArgumentException - Thrown if the object is null or not an ObjectStrokepublic void removeAllObject()
public SpenObjectBase getObject(int index)
index - - The index of the object.IndexOutOfBoundsException - Thrown If the index passed is out of range.public ArrayList<SpenObjectBase> getObjectList()
public int getObjectCount(boolean includeInvisible)
includeInvisible - Set to true to include invisible objects, set to false to not include invisible objects.public SpenObjectBase getObjectByRuntimeHandle(int runtimeHandle)
runtimeHandle - The runtime handle of the object.IllegalArgumentException - Thrown if the runtimeHandle passed cannot be found.public int getObjectIndex(SpenObjectBase object)
object - The object.IllegalStateException - Thrown if the PaintingDoc document is not loaded.IllegalArgumentException - Thrown if the object passed is invalid.public boolean isObjectContained(SpenObjectBase object)
object - The object that you want to check.public SpenObjectBase findTopObjectAtPosition(float x, float y)
x - The x-coordinate value.y - The y-coordinate valueIllegalArgumentException - Thrown if the arguments passed are invalid.public SpenObjectBase findTopObjectAtPosition(float x, float y, float threshold)
x-threshold, y-threshold) to
(x+threshold, y+threshold). x - The x-coordinate value.y - The y-coordinate valuethreshold - The threshold of position.IllegalArgumentException - Thrown if the arguments passed are invalid.public ArrayList<SpenObjectBase> findObjectAtPosition(float x, float y)
x - The specified x-coordinate.y - The specified y-coordinate.IllegalArgumentException - Thrown if the arguments passed are invalid.public ArrayList<SpenObjectBase> findObjectAtPosition(float x, float y, float threshold)
x-threshold, y-threshold) to
(x+threshold, y+threshold). x - The specified x-coordinate.y - The specified y-coordinate.threshold - The threshold of position.IllegalArgumentException - Thrown if the arguments passed are invalid.public ArrayList<SpenObjectBase> findObjectInClosedCurve(PointF[] points)
points - The point array that defines the curves.IllegalArgumentException - Thrown if the arguments passed are invalid.public ArrayList<SpenObjectBase> findObjectInRect(RectF rectf, boolean allAreas)
rectf - The rect to find the objects.allAreas - Set to true to find the objects that only are within the rectf, set to false to include the objects
that partially overlap with the rectf.IllegalArgumentException - If you set invalidpublic int getOrientation()
ORIENTATION_LANDSCAPE,
ORIENTATION_PORTRAITpublic void setVolatileBackgroundImage(Bitmap bitmap)
bitmap - The image bitmap.IllegalArgumentException - Thrown if the bitmap passed is a recycled image.public void setBackgroundImage(String filePath)
filePath - The image file path.IllegalArgumentException - Thrown if the file path passed is invalid or if the file does not exist.public Bitmap getBackgroundImage()
public String getBackgroundImagePath()
public void setBackgroundImageMode(int mode)
mode - The image mode.IllegalArgumentException - Thrown if the mode type is invalid.BACKGROUND_IMAGE_MODE_CENTER,
BACKGROUND_IMAGE_MODE_FIT,
BACKGROUND_IMAGE_MODE_STRETCH,
BACKGROUND_IMAGE_MODE_TILEpublic int getBackgroundImageMode()
BACKGROUND_IMAGE_MODE_CENTER,
BACKGROUND_IMAGE_MODE_FIT,
BACKGROUND_IMAGE_MODE_STRETCH,
BACKGROUND_IMAGE_MODE_TILEpublic void setForegroundImage(Bitmap bitmap)
bitmap - The image bitmapIllegalArgumentException - Thrown if the bitmap passed is invalid or null.public void setForegroundImage(String filePath)
filePath - The image file path.IllegalArgumentException - Thrown if the file path passed is invalid or if the file does not exist.public String getForegroundImagePath()
public Bitmap getForegroundImage()
public void setBackgroundColor(int color)
color - The color in ARGB8888 format.public int getBackgroundColor()
public String getId()
public RectF getDrawnRectOfAllObject()
public boolean isChanged()
public void setExtraDataString(String key, String value)
key - The key for the data.value - The extra string data.IllegalArgumentException - Thrown if the key passed is null.public void setExtraDataStringArray(String key, String[] value)
key - The key for the data.value - The extra string array data.IllegalArgumentException - Thrown if the key passed is null.public void setExtraDataByteArray(String key, byte[] value)
key - The key for the data.value - The extra byte array data.IllegalArgumentException - Thrown if the key passed is null.public void setExtraDataInt(String key, int value)
key - The key for the data.value - The extra integer data.IllegalArgumentException - Thrown if the key passed is null.public String getExtraDataString(String key)
key - The key for the data.public int getExtraDataInt(String key)
key - The key for the data.public String[] getExtraDataStringArray(String key)
key - The key for the data.public byte[] getExtraDataByteArray(String key)
key - The key for the data.public boolean hasExtraDataString(String key)
key - The key for the data.public boolean hasExtraDataInt(String key)
key - The key for the datapublic boolean hasExtraDataStringArray(String key)
key - The key for the datapublic boolean hasExtraDataByteArray(String key)
key - The key for the datapublic void removeExtraDataString(String key)
key - The key for the data.public void removeExtraDataInt(String key)
key - The key for the data.public void removeExtraDataStringArray(String key)
key - The key for the data.public void removeExtraDataByteArray(String key)
key - The key for the data.public void loadObject()
throws IOException
isObjectLoaded() method returns true, but if you create a PaintingDoc with
an SPP file, the isObjectLoaded() method returns false.IOException - Thrown if the PaintingDoc file is not found.isObjectLoaded(),
unloadObject()public void loadAllObjects()
throws IOException
isObjectLoaded() method returns true, but if you create a PaintingDoc with
an SPP file, the isObjectLoaded() method returns false.IOException - Thrown if the PaintingDoc file is not found.isObjectLoaded(),
unloadObject()public void unloadObject()
throws IOException
IllegalStateException - Thrown if the isObjectLoaded() method returns false.IOException - Thrown if the PaintingDoc file is not found.isObjectLoaded(),
loadObject()public boolean isObjectLoaded()
public boolean isAllObjectsLoaded()
public void appendLayer(int id)
throws OutOfMemoryError
SpenPaintingView#setPaintingDoc(SpenPaintingDoc, boolean) method, this layer is
drawn on SpenView after SpenPaintingView#update().id - The ID for the new layer.OutOfMemoryError - Throws if out of memory errorIllegalStateException - Thrown if the ID already exists.IllegalArgumentException - Thrown if the ID is less than 0.public void insertLayer(int id,
int index)
SpenPaintingView#setPaintingDoc(SpenPaintingDoc, boolean) method, this layer is
drawn on SpenPaintingView after SpenPaintingView#update().id - The ID for the new layer.index - The index where the layer is inserted.IllegalStateException - Thrown if the ID already exists.IllegalArgumentException - Thrown if the ID is less than 0.IndexOutOfBoundsException - Thrown if index is less than 0 or greater than total number of layers on PaintingDoc.public void removeLayer(int id)
SpenPaintingView#setPaintingDoc(SpenPaintingDoc, boolean) method, this layer is
drawn on SpenPaintingView after SpenPaintingView#update().id - The ID of the layer.IllegalArgumentException - Thrown if there is only one layer.public void moveLayerIndex(int id,
int step)
id - The ID of the layer.step - the steppublic void setCurrentLayer(int id)
id - The layer ID.IllegalArgumentException - Thrown if the ID passed is invalid.public int getCurrentLayerId()
public int getLayerIndex(int id)
id - The id of specified layer.IllegalArgumentException - Thrown if the layer does not exist.public int getLayerIdByIndex(int index)
index - The layer index.IndexOutOfBoundsException - Thrown if the index passed is not valid.public int getLayerCount()
public void setLayerName(int id,
String name)
id - The layer ID.name - The name that you want to set.IllegalArgumentException - Throw if the ID passed is invalid.public String getLayerName(int id)
id - The layer ID.IllegalArgumentException - Thrown if the ID passed is invalid.public void setLayerEventForwardEnabled(int id,
boolean enable)
id - The layer ID.enable - Set to true to enable the layer to forward unprocessable events to the lower layer, set to false to
disable layer event forwarding.IllegalArgumentException - Thrown if the ID passed is invalid.public boolean isLayerEventForwardEnabled(int id)
id - The layer ID.IllegalArgumentException - Thrown if the ID passed is invalid.public boolean isLayerChanged()
public void setLayerVisibility(int id,
boolean visible)
visible - Set to true to show the specific layer, set to false to hide the specific layer.isLayerVisible(int)public boolean isLayerVisible(int id)
id - The layer ID.true, the specific layer is visible.IllegalArgumentException - Thrown if the ID passed is invalid.setLayerVisibility(int, boolean)public void setObjectListener(SpenPaintingDoc.ObjectListener listener)
listener - The ObjectListener instance to receive object events on the PaintingDoc. Set to null to unregister the
current listener.SpenPaintingDoc.ObjectListenerpublic void setLayerListener(SpenPaintingDoc.LayerListener listener)
listener - The LayerListener instance to receive layer events. Set to null to unregister the
current listener.SpenPaintingDoc.LayerListenerpublic boolean isUndoable()
if (paintingDoc.isUndoable() == true) {
spenSurfaceView.updateUndo(paintingDoc.undo());
}
undo()public boolean isRedoable()
if (paintingDoc.isRedoable() == true) {
spenSurfaceView.updateRedo(paintingDoc.redo());
}
redo()public SpenPaintingDoc.HistoryUpdateInfo[] undo()
if (paintingDoc.isUodoable() == true) {
spenSurfaceView.updateUndo(paintingDoc.undo());
}
isUndoable()public SpenPaintingDoc.HistoryUpdateInfo[] redo()
if (paintingDoc.isRedoable() == true) {
spenSurfaceView.updateRedo(paintingDoc.redo());
}
isRedoable()public SpenPaintingDoc.HistoryUpdateInfo[] undoAll()
onClickbutton(State state, Button button) {
if(state == LONG_PRESS && button = undoButton) {
spenSurfaceView.updateUndo(paintingDoc.undoAll());
}
}
undo()public SpenPaintingDoc.HistoryUpdateInfo[] redoAll()
onClickbutton(State state, Button button) {
if(state == LONG_PRESS && button = redoButton) {
spenSurfaceView.updateRedo(paintingDoc.redoAll());
}
}
redo()public void setUndoLimit(int undoLimit)
paintingDoc.setUndoLimit(100);
undoLimit - The undo command limit.getUndoLimit()public int getUndoLimit()
if (paintingDoc.getLimit() == 0) {
paintingDoc.setUndoLimit(100);
}
setUndoLimit(int)public void clearHistory()
setHistoryListener(HistoryListener)public void clearRedoHistory()
public void setHistoryListener(SpenPaintingDoc.HistoryListener listener)
listener - The HistoryListener instance to receive history events.SpenPaintingDoc.HistoryListenerpublic void setHistoryTag()
undoToTag(),
clearHistoryTag()public void clearHistoryTag()
setHistoryTag()public SpenPaintingDoc.HistoryUpdateInfo[] undoToTag()
IllegalStateException - Thrown if there is no history tag or history tag out of the undo stack.setHistoryTag()public void startHistoryGroup()
stopHistoryGroup()public void stopHistoryGroup()
IllegalStateException - Thrown if the PaintingDoc document stops history group without start.startHistoryGroup()public SpenObjectBase createObject(int type)
type - The object type.SpenObjectBase.TYPE_STROKE onlypublic static boolean isValid(String filePath)
filePath - The absolute path of the file.true, if the specified file is a valid SPP file.false, if the specified file is not a valid SPD file.public static void getSize(String filePath, Integer width, Integer height)
filePath - The absolute path of the file.width - The width of the paintingdoc in pixels. (output parameter)height - The height of the paintingdoc in pixels. (output parameter)IllegalArgumentException - Thrown if the filePath is null.public ArrayList<RectF> getObjectRectList()
public void save(String filepath) throws IOException
filepath - The absolute path of the file.IOException - Thrown if the file is not saved successfully.IllegalArgumentException - If the filepath is invalid.IllegalStateException - Thrown if the document is read only mode.public void attachToFile(String filePath) throws IOException
filePath - The absolute path of the file.IOException - Thrown if the file is not saved successfully.IllegalArgumentException - If the filePath is invalid.public void discard()
throws IOException
close() or discard().
If you use the subordinate classes of a PaintingDoc instance after closing it by calling discard(), an exception is
thrown.
A PaintingDoc cannot be called when it is set (setPaintingDoc) on PaintingView. Initialize the PaintingView with setPaintingDoc(null)
before calling it.
Close controls before calling a PaintingDoc. You cannot call a PaintingDoc with controls displayed.IOException - Thrown if the cache directory or its files cannot be deleted.close()public void close()
throws IOException
IOException - Thrown if the cache directory or its files cannot be deleted.discard()public void close(boolean removeCache)
throws IOException
removeCache - Set to true to remove the cache directory of this PaintingDoc, set to false to not remove the cache
directory.
If you set true, it cause some latency when you open the PaintingDoc file(.spd) again later. Since
the all cache files for this PaintingDoc are removed and all cache files need to be re-created.IOException - Thrown if the cache directory or its files cannot be deleted.discard()public boolean equals(Object o)
public int hashCode()
public void setReplayable(boolean replayable)
throws IOException
IOExceptionpublic boolean isReplayable()