• Keine Ergebnisse gefunden

Splitting Gridlines

Im Dokument Sketching Slides (Seite 77-80)

4.2 Shape Insertion

4.2.6 Splitting Gridlines

Figure 4.7a shows how the user may insert a table column between the two existing ones. The desired outcome is shown in Fig. 4.7b. If the snapping algorithm Alg. 2 computed extremal gridline locations gll = (l, Gl), glr = (r, Gr) with l = r, depending on the direction d computed by the same algorithm, all source gridlines will have been inserted at positionsli, i≥0 if d = low or at l+i, i ≥0 otherwise. The situation for d = high is shown in Fig. 4.8. The two rectanglesA and B are adjacent. They are both bound to gridline g between them. The new rectangleC has been inserted directly on gridline g, i.e., l = r = g.v, gGl and gGr. Because d = high, the gridlines of rectangleChave been inserted right ofg. Gridlinegi in the figure is the rightmost gridline of C and its location is g.v+i.

The algorithm collects the set of gridlinesG, bound to the inserted shapes S, the left-most gridline if d=low or the right-most gridline if d=high. In the example of Fig. 4.8a, since d = high, G := {gi}. G thus contains the right-most newly inserted gridlines with position g.v +i. All gridlines in

CONTRA PRO

Quisque diam sapien, auctor sit amet, lacinia quis, eleifend sit amet, urna.

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit dolor. Curabitur eget magna eget neque bibendum interdum.

Quisque diam sapien, auctor sit amet, lacinia quis, eleifend sit amet, urna.

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit dolor. Curabitur eget magna eget neque bibendum interdum.

Quisque diam sapien, auctor sit amet, lacinia quis, eleifend sit amet, urna.

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit

Praesent pretium ullamcorper urna.

Praesent nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vestibulum neque ut justo. Ut vitae libero ac tellus viverra fringilla. Class aptent taciti sociosqu ad litora torquent per conubia n o s t r a , p e r i n c e p t o s h i m e n a e o s . Pellentesque mi orci, auctor vitae, fringilla eu, rhoncus sit amet, arcu. Pellentesque lacinia venenatis nulla. Sed arcu. Aliquam fringilla lobortis neque. Morbi commodo quam id urna. Donec pretium suscipit dolor. Curabitur eget magna eget neque bibendum interdum.

(a) (b)

Figure 4.7: Snapping the column on the gridline between two columns inserts the column, thus splitting the gridline.

A B

Figure 4.8: Separating adjacent shapes to insert a shape on a gridline.

4.2. SHAPE INSERTION 67 Algorithm 6: MergeGridlines algorithm

Input: A set of gridlines G6=∅ such that ∀g, g0G:g.v =g0.v Output: A single merged gridlinegM

1 begin

2 gMgG

3 GG\{g}

4 foreach gG do

5 if g.f then

6 gM.ftrue

7 end

8 foreach s∈ S do

9 if gs.Gx/y then

10 replace g with gM ins.Gx/y

11 end

12 end

13 end

14 end

G are merged to a single gridline gM. Interval set I is set to the interval of extremal values of the span of gM, i.e., I spans the entire height of shapeC.

In the example, it follows that gM =gi.

In the following, every shapes∈ S\Sthat is attached to a gridlineglGl

is considered. For each shape,Is is set to the spans covers ongl in direction d. In the example above, both A and B are attached to gridline g. Because d = high, Is is the span on the right of g. This span is empty for shape A because it touchesg from the left. Is contains a single interval for shape B.

Now,I is the span ofgM, i.e., of the new gridline that is squeezed between A andB. Is is the span ofB at its original position. BecauseIIs6=∅, the left side ofB should be pushed rightwards togM. Intuitively, this means that if C were inserted with zero width at gridline g and then slowly widened, shapes C and B would collide and shape C should push B rightwards as shown in Fig. 4.8b.

Alternatively, if C were smaller, the situation of Fig. 4.9 may arise were IIs 6= ∅ and IIs. In this case, shape B is not moved but everything is left as is. As a result, shape C is inserted to the right of g as before but inside B.

Algorithm 7: SplitGridline

Input: Inserted shapes S, gridline location gll(l, Gl), insertion direction d

1 begin

2 G← ∅

3 if d=lowthen

4 G← {g |g.v = mingi∈s.Gx/y,s∈S(gi.v)}

5 else

6 G← {g |g.v = maxgi∈s.Gx/y,s∈S(gi.v)}

7 end

8 gM ←MergeGridlines(G)

9 ISspan(gM, d=low ? high:low)

10 if I 6=∅ then

11 I ← {(min(a0,b0)∈I(a0),max(a0,b0)∈I(b0))}

12 foreach glGl∧ ¬gl.f do

13 foreach s∈ S\S such that gls.Gx/y do

14 Iss.spanx/y(gl, d)

15 if IsI 6=∅ ∧I 6⊂Is then

16 replacegl with gM ins.Gx/y

17 end

18 end

19 end

20 end

21 end

Im Dokument Sketching Slides (Seite 77-80)