Undo/Redo Operations in Bitmap-Based Collaborative Graphic Editing Systems Liping Gao(), Fangyu Yu, Qiongqiong Fu, Yuben Zhang, Shanshan Wang, and Naixue Xiong School of Optical-Electrical and Computer Engineering, University of Shanghai for Science and Technology Shanghai, People’s Republic of China
[email protected], {fangyuyu,junefu}@st.usst.edu.cn, {yubenzhang,xiongnaixue}@gmail.com,
[email protected]
Abstract. Real-time collaborative graphic editors allow a group of users to view and edit the same graphic document at the same time from geographically dispersed sites connected by communication networks. Bitmap-based graphic editing systems are special collaborative editing systems, and Undo/Redo operations are intricate problems in this field. Existing solutions add extra space, thus showing low efficiency of the algorithms. In this paper, based on Multiversion strategy, we propose a new solution to solve the Undo/Redo consistency problem, and consider three possible cases: all-causal, all-independent and causal-independent-mixed operations. In addition, compared with previous collaborative algorithms, the algorithm proposed in this paper supports selective Undo, without requiring additional space and the implementation of Undo/Redo is more flexible. Keywords: Real-time collaboration · Bitmap-based document model · Graphic editing system · Multi-version strategy · Undo/Redo · Selective undo
1
Introduction
Collaborative Editing Systems allow a group of users to edit the same document at the same time from geographically dispersed sites, which show higher editing system efficiency than previous single-user systems. Meanwhile, the effect of multiple-user editing system preserves all users’ intentions with highly synchronized interactivity, that is to say, the work concurrently produced by all users can always be retained whether there are conflicts or not. In recent years, the research on multi-user collaborative systems has gained great attention from research field. Real-time collaborative graphic editing systems can be classified into three categories: objected-based, bitmap-based and hybrid [1]. Object-based editing systems edit the content as an object, such as points, lines, rectangles, circles, etc., and each object has attributes such as color, size, position, etc. Graphic objects can be created, updated, and deleted by users, and Update operations can be applied to change the © Springer International Publishing Switzerland 2015 Q. Zu et al. (Eds.): HCC 2014, LNCS 8944, pp. 501–511, 2015. DOI: 10.1007/978-3-319-15554-8_41
502
L. Gao et al.
attributes of the target object. Many research prototypes have been developed in this field, including Co-Microsoft PowerPoint, Co-AutoCAD, Co-Microsoft Visio, etc. Bitmap-based editing systems divide the panel into pixels with minimal granularity, and users can modify the pixel’s attributes (such as color) only in this panel. For example, Microsoft Paint is one of such bitmap-based systems. In hybrid systems, single-user applications are widely used, such as CorelDraw, Adobe Photoshop, etc. Existing researches on collaborative graphic editors are mostly based on object model [2,3,4,5], and only few works have been done on bitmap-based systems. However, bitmap-based system has irreplaceable advantages over object-based system since it has a simple model and its editing software does well in post-processing of image, which makes it very significant in this research. The previous works on Undo in bitmap-based graphic editing systems include [1], and Wang represents conflict relations between operations with a Directed Graph Structure (DGS) and a Point List. Due to the uncertainty and dynamics of operations, the Point List has to be changed constantly along with changing DGS, which causes it difficult to be maintained. In addition, DGS adds extra space because of additional storage, resulting in low efficiency. In this paper, a new approach to resolve Undo/Redo problems are proposed, which fully combines the specificity of bitmap-based systems with Multi-version strategy. Another research work in graphic editing system [6] considers the combination effect of operations based on Multi-version strategy, so that even a few operations can generate lots of versions. For example, only three operations:O1, O2 and O3 can generate 81 versions, which are not easy to be maintained and the efficiency of algorithm is low. And based on those, this paper just preserves the intentions of all operations separately so that the versions generated are not so much, making it easier to resolve conflict resolution and helpful to study Undo/Redo problems further. Moreover, compared with previous collaborative algorithms, it is more flexible to achieve. The following paper is organized as follows. In Section 2, some previous works and basic concepts about Multi-version strategy are introduced briefly. A bitmapbased document model is created and some related operations are presented in Section 3 and 4. In Section 5, a new approach is proposed to resolve Undo/Redo problems, the efficiency of the algorithm is analyzed and the validity and correctness of the design is verified, which is the focus of the paper. Finally, the paper is concluded with a brief summary of major contributions and further work.
2
Related Work
In collaborative editing systems, Undo is a very important function, because a major mistake can be easily made by a mouse click only. Therefore, it is urgently required that users can recover from erroneous operations, learn new system features and explore alternative solutions by Undo. So far, the research of Undo on text editing systems is widely used in many fields [7,8,9,10,11], while the study on graphic editing systems is largely focused on object-based document model and has relatively mature Undo algorithms, such as [12]. In contrast, the research of Undo on bitmap-based graphic editing systems is quite few. Among them, [1] describes the conflict relations of operations with a Direct
Undo/Redo Operations in Bitmap-Based Collaborative Graphic Editing Systems
503
Graph Structure (DGS). In the DGS, a Point List (PL) is added to point to an operation that is directly overlapping with the current operation. When undoing an operation, the PL changes and updates the DGS dynamically to generate a new DGS. Obviously, due to the uncertainty and dynamics of operations, the PL has to be changing continually, so is the GDS. Especially when it occurs that an operation is undone mistakenly, the whole DGS might be affected. Furthermore, the Undo algorithm’s efficiency is low because the DGS has to be restored in an additional space. In this paper, we propose a new Undo approach which has the advantage of without taking up extra space, reducing space costs and increasing the algorithm’s efficiency. In addition, another article of bitmap-based editing systems [6], takes the combination effect of operations into account, so that it can respect the intentions of all users by Multi-version strategy. However, with the idea of Multi-version, even a few operations can generate many versions and thus make it tough for system maintenance. Therefore, based on Multi-version strategy which preserves each user’s separate intention, this paper designs a new Undo/Redo approach, which takes full advantage of the bitmap’s specificity and has a more concise and flexible algorithm than previous collaborative ones. Here, we also give some basic definitions of multiple versions [13]. Definition 1: causal ordering relation “→” Given two operations O1 and O2, generated at sites i and j, then O1→O2, iff: (1) i=j and the generation of O1 happened before the generation of O2, or (2) i≠j and the execution of O1 at site j happened before the generation of O2, or (3) there exists an operation Ox, such that O1 →Ox and Ox →O2. Definition 2: dependent and independent operations Given two operations O1 and O2. (1) O2 is dependent on O1, iff O1→O2. (2) O1 and O2 are independent (or concurrent), denoted as O1 || O2, iff neither O1→O2, nor O2→O1. Definition 3: consistency model (CCI) A collaborative editing system is said to be consistent if it always maintains the following three properties: Convergence: when all sites have executed the same set of operations, the copies of the shared document at all sites are identical. Causality-preservation: for any pair of operations O1 and O2, if O1→O2, then O1 is executed before O2 at all sites. Intention-preservation: for any operation O, both the local and remote executing effects of O equal to O’s intention, and if there exists an operation Ox, such that Ox || O, then the execution effect of Ox does not interfere with the execution effect of O, and vice versa.
3
A Bitmap-Based Document Model
In this paper, we follow to use our research fellow’s outcome: the bitmap-based document model [6], and it will be introduced briefly. The bitmap-based model is based on pixels in matrix form, and an operation with the color of each pixel is defined as a
504
L. Gao et al.
meta-operation. It should be noted that pixels have two properties: Location and Color, as shown in Fig. 1.
Fig. 1. The Bitmap-based Document Model
Figure 1 is a 4*4 pixel panel, and each pixel can be represented as Block (Location, Color). In the panel, Location represents pixel’s coordinates, which is a unique identifier of pixels and can be expressed in a two-dimensional coordinate(x, y) form. As shown in Fig. 1, the coordinate of the color blue is: (2, 2). Color is pixels’ another attribute. For example, the last row in the panel can be expressed as: ((3, 0), Green), ((3, 1), Green), ((3, 2), White), ((3, 3), White). In bitmap-based systems, each pixel’s attributes can exist independently due to the independence between pixels. Note that if the drawing area includes more than one operation, it can be divided into squares with equal size until each area includes only one operation. Actually, the drawing area is not necessarily a square, however, in this paper, we define it as a square for simplicity.
4
Bitmap Operations
In this section, some definitions of bitmap operations are introduced in detail. Definition 4: SetColor(SiteID, C(Location), ColorNew, ColorOld): SiteID indicates the site identifier of operations, C(Location) indicates the pixels set that is affected by operations, ColorNew indicates the new color that is set by users(CN, for short), and ColorOld indicates the initial color of pixels(CO, for short). For example, the last row in Fig. 1 above can be expressed as: SetColor(SiteID, C, Green, White) (Wherein, C is the set of (3, 0) and (3, 1)). Definition 5: Version(Id, State): Id indicates the version number, which is the unique identifier of versions; While State indicates the display state of versions, wherein 0: the Version is not visible, 1: the Version is visible. In default, the Version is visible. Definition 6: Algebra Operations [6] Given two operations O1 and O2, with the corresponding pixels set: C1 and C2, respectively. Now three algebra operations: join, subtract and merge are defined as follows. O1∩O2: it denotes the intersection of C1 and C2, i.e, the pixels set which is the overlapping portion of C1 and C2. O1-O2: it denotes the complementary set of C1 on C2, i.e, the pixels set which is included in C1 but not in C2.
Undo/Redo Operations in Bitmap-Based Collaborative Graphic Editing Systems
505
∪
O1 O2: it denotes the union set of C1 and C2, i.e, the pixels set which is included both in C1 and C2. Definition 7: Conflict Relation “ ⊗ ” [13] Given two operations O1 and O2, they conflict with each other, denoted as O1 ⊗ O2, iff: (1) O1 || O2; (2) O1 ∩ O2 ≠ { }; (3) Att.Type(O1) = Att.Type(O2); (4) Att.Value(O1) ≠ Att.Value(O2). It is worth mentioning that, the attribute type (i.e, Att.Type) refers to the color only in this paper.
⊙ ⊙
Definition 8: Compatible Relation “ ” [13] Given two operations O1 and O2, if they do not conflict with each other, they are compatible relations, denoted as O1 O2.
5
Undo Consistency Maintenance Strategy
5.1
Overview of the Undo Algorithm
In practical collaborative graphic editing systems, it occurs in some cases that users discover mistaken operations, explore new ideas by try-and -failure and find alternative solutions by backtracking, which makes it necessary to undo one or some operations. Most importantly, the effect of undoing an operation must be just as it has never appeared. Therefore, Undo is very essential in graphic editing systems. Undo satisfies the following properties: (1) the same operation is not allowed to be undone continuously or there exists such a case that Undo(Oi),...,Undo(Oi). (2) Selective Undo is supported, that is to say, we can undo any operation at any time. Equally, for the Any-Undo algorithm, three cases should be considered: all-causal, all-independent and causal-independent-mixed operations. Given a series of executed operations O1, O2,..., On, and Oi is the operation to be undone. Wherein, all executed operations are restored in HB, i.e, HB= {O1, O2,...,Oi...,On}. If Oi has been undone, HB={O1, O2,...,Oi...,On, Ōi}={O1, O2,...,Oi, Ōi,...,On}={O1, O2,...,Oi-1, Oi*, Oi+1...,On} by using LTranspose(HB(i+1, n+1)) [8]. The Any-Undo algorithm aims to undo any operation Oi on the basis of existing versions. Algorithm2:Any-Undo(Oi, Version, HB) Given executed operations O1,O2,...,On , and Oi is the operation to be undone. Begin: 1. HB={O1, O2,...,Oi...,On}; 2. Switch(count) { 3. Case 1: the executed operations’ relation is: O1→O2→,...,→Oi→...,→On 4. All-Causal(Oi, Version, HB); 5. Case 2: the executed operations’ relation is: O1 || O2 ||,..., || Oi ||..., || On 6. All-Independent(Oi, Version, HB); 7. Case 3: the executed operations’ relation is: →,→, ||, ||...,→... 8. CI-Mixed(Oi, Version, HB);
506
L. Gao et al.
9. } 10. C=Oi-O1-O2-...-On; 11. If C≠{ } then 12. Version ←{SetColor(Si, C, O1.CO, Oi.CN)}; //the zone C shows the color of the initial state 13. else 14. do nothing; 15. end if 16. return Version; End The All-Causal function specifies the case that all executed operations in HB are causal preceding Oi, as shown in Function 4. Function4:All-Causal(Oi, Version, HB) Case 1: all-causal relations Begin: 1. for(j=i-1; j