Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/virtuosotechnologies/asaph/standardgui/EditorSelection.java


1   /*
2   ================================================================================
3   
4     FILE:  EditorSelection.java
5     
6     PROJECT:
7     
8       Asaph
9     
10    CONTENTS:
11    
12      The song body editor: An object that stores the current selection
13    
14    PROGRAMMERS:
15    
16      Daniel Azuma (DA)  <dazuma@kagi.com>
17    
18    COPYRIGHT:
19    
20      Copyright (C) 2003  Daniel Azuma  (dazuma@kagi.com)
21      
22      This program is free software; you can redistribute it and/or
23      modify it under the terms of the GNU General Public License as
24      published by the Free Software Foundation; either version 2
25      of the License, or (at your option) any later version.
26      
27      This program is distributed in the hope that it will be useful,
28      but WITHOUT ANY WARRANTY; without even the implied warranty of
29      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30      GNU General Public License for more details.
31      
32      You should have received a copy of the GNU General Public
33      License along with this program; if not, write to
34        Free Software Foundation, Inc.
35        59 Temple Place, Suite 330
36        Boston, MA 02111-1307 USA
37  
38  ================================================================================
39  */
40  
41  
42  package com.virtuosotechnologies.asaph.standardgui;
43  
44  
45  /**
46   * The song body editor: selection
47   */
48  /*package*/ class EditorSelection
49  {
50    private SongBodyEditorPane pane_;
51    private boolean valid_;
52    
53    private int startBlock_;
54    private int startBlock2_;
55    private int endBlock_;
56    private int containerBlock_;
57    private int startLine_;
58    private int startLine2_;
59    private int endLine_;
60    private int containerLine_;
61    private int startTextView_;
62    private int startTextView2_;
63    private int startTextPos_;
64    private int startTextPos2_;
65    private int endTextView_;
66    private int endTextPos_;
67    private int containerChordGroup_;
68    
69    private Float lastX_;
70    
71    
72    /*package*/ EditorSelection(
73      SongBodyEditorPane pane)
74    {
75      pane_ = pane;
76      valid_ = true;
77      startBlock_ = -1;
78      startBlock2_ = -1;
79      endBlock_ = -1;
80      containerBlock_ = -1;
81      startLine_ = -1;
82      startLine2_ = -1;
83      endLine_ = -1;
84      containerLine_ = -1;
85      startTextView_ = -1;
86      startTextPos_ = -1;
87      startTextView2_ = -1;
88      startTextPos2_ = -1;
89      endTextView_ = -1;
90      endTextPos_ = -1;
91      containerChordGroup_ = -1;
92      lastX_ = null;
93    }
94    
95    
96    // Accessors
97    
98    /*package*/ EditorSelection createCopy()
99    {
100     EditorSelection ret = new EditorSelection(null);
101     ret.startBlock_ = startBlock_;
102     ret.startBlock2_ = startBlock2_;
103     ret.endBlock_ = endBlock_;
104     ret.containerBlock_ = containerBlock_;
105     ret.startLine_ = startLine_;
106     ret.startLine2_ = startLine2_;
107     ret.endLine_ = endLine_;
108     ret.containerLine_ = containerLine_;
109     ret.startTextView_ = startTextView_;
110     ret.startTextPos_ = startTextPos_;
111     ret.startTextView2_ = startTextView2_;
112     ret.startTextPos2_ = startTextPos2_;
113     ret.endTextView_ = endTextView_;
114     ret.endTextPos_ = endTextPos_;
115     ret.containerChordGroup_ = containerChordGroup_;
116     return ret;
117   }
118   
119   
120   /*package*/ EditorSelection createCopyOfEnd()
121   {
122     EditorSelection ret = new EditorSelection(null);
123     ret.startBlock_ = endBlock_;
124     ret.startBlock2_ = endBlock_;
125     ret.endBlock_ = endBlock_;
126     ret.containerBlock_ = containerBlock_;
127     ret.startLine_ = endLine_;
128     ret.startLine2_ = endLine_;
129     ret.endLine_ = endLine_;
130     ret.containerLine_ = containerLine_;
131     ret.startTextView_ = endTextView_;
132     ret.startTextPos_ = endTextPos_;
133     ret.startTextView2_ = endTextView_;
134     ret.startTextPos2_ = endTextPos_;
135     ret.endTextView_ = endTextView_;
136     ret.endTextPos_ = endTextPos_;
137     ret.containerChordGroup_ = containerChordGroup_;
138     return ret;
139   }
140   
141   
142   /*package*/ boolean isOriginal()
143   {
144     return pane_ != null;
145   }
146   
147   
148   /*package*/ boolean hasSelection()
149   {
150     return startBlock_ != -1 || (containerBlock_ != -1 &&
151       (startLine_ != -1 || (containerLine_ != -1 &&
152         startTextView_ != -1)));
153   }
154   
155   
156   /*package*/ boolean isSinglePointSelection()
157   {
158     if (startBlock_ != -1)
159     {
160       return startBlock2_ == startBlock_ && endBlock_ == startBlock_;
161     }
162     else if (startLine_ != -1)
163     {
164       return startLine2_ == startLine_ && endLine_ == startLine_;
165     }
166     else if (startTextView_ != -1)
167     {
168       return startTextView2_ == startTextView_ && endTextView_ == startTextView_ &&
169         startTextPos2_ == startTextPos_ && endTextPos_ == startTextPos_;
170     }
171     else
172     {
173       return false;
174     }
175   }
176   
177   
178   /*package*/ boolean isSinglePointStarter()
179   {
180     if (startBlock_ != -1)
181     {
182       return startBlock2_ == startBlock_;
183     }
184     else if (startLine_ != -1)
185     {
186       return startLine2_ == startLine_;
187     }
188     else if (startTextView_ != -1)
189     {
190       return startTextView2_ == startTextView_ && startTextPos2_ == startTextPos_;
191     }
192     return false;
193   }
194   
195   
196   /*package*/ boolean isBlockSelection()
197   {
198     return startBlock_ != -1;
199   }
200   
201   
202   /*package*/ int getTopBlockPos()
203   {
204     if (startBlock_ <= endBlock_ && startBlock_ <= startBlock2_)
205     {
206       return startBlock_;
207     }
208     else if (startBlock2_ <= endBlock_ && startBlock2_ <= startBlock_)
209     {
210       return startBlock2_;
211     }
212     else
213     {
214       return endBlock_;
215     }
216   }
217   
218   
219   /*package*/ int getBottomBlockPos()
220   {
221     if (startBlock_ >= endBlock_ && startBlock_ >= startBlock2_)
222     {
223       return startBlock_;
224     }
225     else if (startBlock2_ >= endBlock_ && startBlock2_ >= startBlock_)
226     {
227       return startBlock2_;
228     }
229     else
230     {
231       return endBlock_;
232     }
233   }
234   
235   
236   /*package*/ int getStartBlockPos()
237   {
238     return startBlock_;
239   }
240   
241   
242   /*package*/ int getStartBlockPos2()
243   {
244     return startBlock2_;
245   }
246   
247   
248   /*package*/ int getEndBlockPos()
249   {
250     return endBlock_;
251   }
252   
253   
254   /*package*/ int getContainingBlock()
255   {
256     return containerBlock_;
257   }
258   
259   
260   /*package*/ boolean isLineSelection()
261   {
262     return containerBlock_ != -1 && startLine_ != -1;
263   }
264   
265   
266   /*package*/ int getTopLinePos()
267   {
268     if (containerBlock_ == -1)
269     {
270       return -1;
271     }
272     if (startLine_ <= endLine_ && startLine_ <= startLine2_)
273     {
274       return startLine_;
275     }
276     else if (startLine2_ <= endLine_ && startLine2_ <= startLine_)
277     {
278       return startLine2_;
279     }
280     else
281     {
282       return endLine_;
283     }
284   }
285   
286   
287   /*package*/ int getBottomLinePos()
288   {
289     if (containerBlock_ == -1)
290     {
291       return -1;
292     }
293     if (startLine_ >= endLine_ && startLine_ >= startLine2_)
294     {
295       return startLine_;
296     }
297     else if (startLine2_ >= endLine_ && startLine2_ >= startLine_)
298     {
299       return startLine2_;
300     }
301     else
302     {
303       return endLine_;
304     }
305   }
306   
307   
308   /*package*/ int getStartLinePos()
309   {
310     if (containerBlock_ == -1)
311     {
312       return -1;
313     }
314     else
315     {
316       return startLine_;
317     }
318   }
319   
320   
321   /*package*/ int getStartLinePos2()
322   {
323     if (containerBlock_ == -1)
324     {
325       return -1;
326     }
327     else
328     {
329       return startLine2_;
330     }
331   }
332   
333   
334   /*package*/ int getEndLinePos()
335   {
336     if (containerBlock_ == -1)
337     {
338       return -1;
339     }
340     else
341     {
342       return endLine_;
343     }
344   }
345   
346   
347   /*package*/ int getContainingLine()
348   {
349     if (containerBlock_ == -1)
350     {
351       return -1;
352     }
353     else
354     {
355       return containerLine_;
356     }
357   }
358   
359   
360   /*package*/ boolean isTextSelection()
361   {
362     return containerBlock_ != -1 && containerLine_ != -1 && containerChordGroup_ == -1;
363   }
364   
365   
366   /*package*/ int getStartTextView()
367   {
368     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
369     {
370       return -1;
371     }
372     else
373     {
374       return startTextView_;
375     }
376   }
377   
378   
379   /*package*/ int getStartTextView2()
380   {
381     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
382     {
383       return -1;
384     }
385     else
386     {
387       return startTextView2_;
388     }
389   }
390   
391   
392   /*package*/ int getEndTextView()
393   {
394     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
395     {
396       return -1;
397     }
398     else
399     {
400       return endTextView_;
401     }
402   }
403   
404   
405   /*package*/ int getStartTextPos()
406   {
407     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
408     {
409       return -1;
410     }
411     else
412     {
413       return startTextPos_;
414     }
415   }
416   
417   
418   /*package*/ int getStartTextPos2()
419   {
420     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
421     {
422       return -1;
423     }
424     else
425     {
426       return startTextPos2_;
427     }
428   }
429   
430   
431   /*package*/ int getEndTextPos()
432   {
433     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
434     {
435       return -1;
436     }
437     else
438     {
439       return endTextPos_;
440     }
441   }
442   
443   
444   /*package*/ int getLeftTextView()
445   {
446     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
447     {
448       return -1;
449     }
450     else if (startTextView_ <= startTextView2_ && startTextView_ <= endTextView_)
451     {
452       return startTextView_;
453     }
454     else if (startTextView2_ <= startTextView_ && startTextView2_ <= endTextView_)
455     {
456       return startTextView2_;
457     }
458     else
459     {
460       return endTextView_;
461     }
462   }
463   
464   
465   /*package*/ int getRightTextView()
466   {
467     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
468     {
469       return -1;
470     }
471     else if (startTextView_ >= startTextView2_ && startTextView_ >= endTextView_)
472     {
473       return startTextView_;
474     }
475     else if (startTextView2_ >= startTextView_ && startTextView2_ >= endTextView_)
476     {
477       return startTextView2_;
478     }
479     else
480     {
481       return endTextView_;
482     }
483   }
484   
485   
486   /*package*/ int getLeftTextPos()
487   {
488     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
489     {
490       return -1;
491     }
492     else if ((startTextView_ < startTextView2_ || (startTextView_ == startTextView2_ && startTextPos_ <= startTextPos2_)) &&
493       (startTextView_ < endTextView_ || (startTextView_ == endTextView_ && startTextPos_ <= endTextPos_)))
494     {
495       return startTextPos_;
496     }
497     else if ((startTextView2_ < startTextView_ || (startTextView2_ == startTextView_ && startTextPos2_ <= startTextPos_)) &&
498       (startTextView2_ < endTextView_ || (startTextView2_ == endTextView_ && startTextPos2_ <= endTextPos_)))
499     {
500       return startTextPos2_;
501     }
502     else
503     {
504       return endTextPos_;
505     }
506   }
507   
508   
509   /*package*/ int getRightTextPos()
510   {
511     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ != -1)
512     {
513       return -1;
514     }
515     else if ((startTextView_ > startTextView2_ || (startTextView_ == startTextView2_ && startTextPos_ >= startTextPos2_)) &&
516       (startTextView_ > endTextView_ || (startTextView_ == endTextView_ && startTextPos_ >= endTextPos_)))
517     {
518       return startTextPos_;
519     }
520     else if ((startTextView2_ > startTextView_ || (startTextView2_ == startTextView_ && startTextPos2_ >= startTextPos_)) &&
521       (startTextView2_ > endTextView_ || (startTextView2_ == endTextView_ && startTextPos2_ >= endTextPos_)))
522     {
523       return startTextPos2_;
524     }
525     else
526     {
527       return endTextPos_;
528     }
529   }
530   
531   
532   /*package*/ boolean isChordSelection()
533   {
534     return containerBlock_ != -1 && containerLine_ != -1 && containerChordGroup_ != -1;
535   }
536   
537   
538   /*package*/ int getChordGroup()
539   {
540     if (containerBlock_ == -1 || containerLine_ == -1)
541     {
542       return -1;
543     }
544     else
545     {
546       return containerChordGroup_;
547     }
548   }
549   
550   
551   /*package*/ int getStartChordView()
552   {
553     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
554     {
555       return -1;
556     }
557     else
558     {
559       return startTextView_;
560     }
561   }
562   
563   
564   /*package*/ int getStartChordView2()
565   {
566     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
567     {
568       return -1;
569     }
570     else
571     {
572       return startTextView2_;
573     }
574   }
575   
576   
577   /*package*/ int getEndChordView()
578   {
579     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
580     {
581       return -1;
582     }
583     else
584     {
585       return endTextView_;
586     }
587   }
588   
589   
590   /*package*/ int getStartChordPos()
591   {
592     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
593     {
594       return -1;
595     }
596     else
597     {
598       return startTextPos_;
599     }
600   }
601   
602   
603   /*package*/ int getStartChordPos2()
604   {
605     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
606     {
607       return -1;
608     }
609     else
610     {
611       return startTextPos2_;
612     }
613   }
614   
615   
616   /*package*/ int getEndChordPos()
617   {
618     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
619     {
620       return -1;
621     }
622     else
623     {
624       return endTextPos_;
625     }
626   }
627   
628   
629   /*package*/ int getLeftChordView()
630   {
631     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
632     {
633       return -1;
634     }
635     else if (startTextView_ <= startTextView2_ && startTextView_ <= endTextView_)
636     {
637       return startTextView_;
638     }
639     else if (startTextView2_ <= startTextView_ && startTextView2_ <= endTextView_)
640     {
641       return startTextView2_;
642     }
643     else
644     {
645       return endTextView_;
646     }
647   }
648   
649   
650   /*package*/ int getRightChordView()
651   {
652     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
653     {
654       return -1;
655     }
656     else if (startTextView_ >= startTextView2_ && startTextView_ >= endTextView_)
657     {
658       return startTextView_;
659     }
660     else if (startTextView2_ >= startTextView_ && startTextView2_ >= endTextView_)
661     {
662       return startTextView2_;
663     }
664     else
665     {
666       return endTextView_;
667     }
668   }
669   
670   
671   /*package*/ int getLeftChordPos()
672   {
673     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
674     {
675       return -1;
676     }
677     else if ((startTextView_ < startTextView2_ || (startTextView_ == startTextView2_ && startTextPos_ <= startTextPos2_)) &&
678       (startTextView_ < endTextView_ || (startTextView_ == endTextView_ && startTextPos_ <= endTextPos_)))
679     {
680       return startTextPos_;
681     }
682     else if ((startTextView2_ < startTextView_ || (startTextView2_ == startTextView_ && startTextPos2_ <= startTextPos_)) &&
683       (startTextView2_ < endTextView_ || (startTextView2_ == endTextView_ && startTextPos2_ <= endTextPos_)))
684     {
685       return startTextPos2_;
686     }
687     else
688     {
689       return endTextPos_;
690     }
691   }
692   
693   
694   /*package*/ int getRightChordPos()
695   {
696     if (containerBlock_ == -1 || containerLine_ == -1 || containerChordGroup_ == -1)
697     {
698       return -1;
699     }
700     else if ((startTextView_ > startTextView2_ || (startTextView_ == startTextView2_ && startTextPos_ >= startTextPos2_)) &&
701       (startTextView_ > endTextView_ || (startTextView_ == endTextView_ && startTextPos_ >= endTextPos_)))
702     {
703       return startTextPos_;
704     }
705     else if ((startTextView2_ > startTextView_ || (startTextView2_ == startTextView_ && startTextPos2_ >= startTextPos_)) &&
706       (startTextView2_ > endTextView_ || (startTextView2_ == endTextView_ && startTextPos2_ >= endTextPos_)))
707     {
708       return startTextPos2_;
709     }
710     else
711     {
712       return endTextPos_;
713     }
714   }
715   
716   
717   /*package*/ Float getLastX()
718   {
719     return lastX_;
720   }
721   
722   
723   // Mutators
724   
725   /*package*/ void invalidate()
726   {
727     assert pane_ != null;
728     valid_ = false;
729   }
730   
731   
732   private void preModify()
733   {
734     if (pane_ != null && valid_)
735     {
736       pane_.repaintSelectionWithoutScrolling();
737     }
738   }
739   
740   
741   private void postModify(
742     boolean scroll)
743   {
744     lastX_ = null;
745     if (pane_ != null)
746     {
747       if (scroll)
748       {
749         pane_.repaintAndScrollToSelection();
750       }
751       else
752       {
753         pane_.repaintSelectionWithoutScrolling();
754       }
755       pane_.updateCommandEnabling();
756       valid_ = true;
757     }
758   }
759   
760   
761   /*package*/ void set(
762     EditorSelection sel,
763     boolean scroll)
764   {
765     preModify();
766     startBlock_ = sel.startBlock_;
767     startBlock2_ = sel.startBlock2_;
768     endBlock_ = sel.endBlock_;
769     containerBlock_ = sel.containerBlock_;
770     startLine_ = sel.startLine_;
771     startLine2_ = sel.startLine2_;
772     endLine_ = sel.endLine_;
773     containerLine_ = sel.containerLine_;
774     startTextView_ = sel.startTextView_;
775     startTextPos_ = sel.startTextPos_;
776     startTextView2_ = sel.startTextView2_;
777     startTextPos2_ = sel.startTextPos2_;
778     endTextView_ = sel.endTextView_;
779     endTextPos_ = sel.endTextPos_;
780     containerChordGroup_ = sel.containerChordGroup_;
781     postModify(scroll);
782   }
783   
784   
785   /*package*/ void clear()
786   {
787     boolean hadSelection = hasSelection();
788     if (hadSelection)
789     {
790       preModify();
791     }
792     containerBlock_ = -1;
793     startBlock_ = -1;
794     endBlock_ = -1;
795     if (hadSelection)
796     {
797       postModify(false);
798     }
799   }
800   
801   
802   /*package*/ void setBlockSelection(
803     int startPos,
804     int endPos,
805     boolean scroll)
806   {
807     preModify();
808     containerBlock_ = -1;
809     startBlock_ = startPos;
810     startBlock2_ = startPos;
811     endBlock_ = endPos;
812     postModify(scroll);
813   }
814   
815   
816   /*package*/ void startBlockSelection(
817     int startPos,
818     int startPos2,
819     boolean scroll)
820   {
821     preModify();
822     containerBlock_ = -1;
823     startBlock_ = startPos;
824     startBlock2_ = startPos2;
825     endBlock_ = startPos2;
826     postModify(scroll);
827   }
828   
829   
830   /*package*/ void extendBlockSelection(
831     int endPos,
832     boolean scroll)
833   {
834     assert isBlockSelection();
835     if (endPos != endBlock_)
836     {
837       preModify();
838       endBlock_ = endPos;
839       postModify(scroll);
840     }
841   }
842   
843   
844   /*package*/ void prepareSelectionInsideBlock(
845     int blockPos)
846   {
847     if (containerBlock_ != blockPos)
848     {
849       if (hasSelection())
850       {
851         preModify();
852       }
853       containerBlock_ = blockPos;
854       startBlock_ = -1;
855       startBlock2_ = -1;
856       endBlock_ = -1;
857       containerLine_ = -1;
858       startLine_ = -1;
859       startLine2_ = -1;
860       endLine_ = -1;
861     }
862   }
863   
864   
865   /*package*/ void setLineSelection(
866     int startPos,
867     int endPos,
868     boolean scroll)
869   {
870     assert containerBlock_ != -1;
871     preModify();
872     containerLine_ = -1;
873     startLine_ = startPos;
874     startLine2_ = startPos;
875     endLine_ = endPos;
876     postModify(scroll);
877   }
878   
879   
880   /*package*/ void startLineSelection(
881     int startPos,
882     int startPos2,
883     boolean scroll)
884   {
885     assert containerBlock_ != -1;
886     preModify();
887     containerLine_ = -1;
888     startLine_ = startPos;
889     startLine2_ = startPos2;
890     endLine_ = startPos2;
891     postModify(scroll);
892   }
893   
894   
895   /*package*/ void extendLineSelection(
896     int endPos,
897     boolean scroll)
898   {
899     assert isLineSelection();
900     if (endPos != endLine_)
901     {
902       preModify();
903       endLine_ = endPos;
904       postModify(scroll);
905     }
906   }
907   
908   
909   /*package*/ void prepareSelectionInsideLine(
910     int linePos)
911   {
912     assert containerBlock_ != -1;
913     if (containerLine_ != linePos)
914     {
915       if (hasSelection())
916       {
917         preModify();
918       }
919       containerLine_ = linePos;
920       startLine_ = -1;
921       startLine2_ = -1;
922       endLine_ = -1;
923       startTextView_ = -1;
924       startTextPos_ = -1;
925       startTextView2_ = -1;
926       startTextPos2_ = -1;
927       endTextView_ = -1;
928       endTextPos_ = -1;
929     }
930   }
931   
932   
933   /*package*/ void setTextSelection(
934     int startView,
935     int startPos,
936     int endView,
937     int endPos,
938     boolean scroll)
939   {
940     assert containerBlock_ != -1;
941     assert containerLine_ != -1;
942     preModify();
943     containerChordGroup_ = -1;
944     startTextView_ = startView;
945     startTextPos_ = startPos;
946     startTextView2_ = startView;
947     startTextPos2_ = startPos;
948     endTextView_ = endView;
949     endTextPos_ = endPos;
950     postModify(scroll);
951   }
952   
953   
954   /*package*/ void startTextSelection(
955     int startView,
956     int startPos,
957     int startView2,
958     int startPos2,
959     boolean scroll)
960   {
961     assert containerBlock_ != -1;
962     assert containerLine_ != -1;
963     preModify();
964     containerChordGroup_ = -1;
965     startTextView_ = startView;
966     startTextPos_ = startPos;
967     startTextView2_ = startView2;
968     startTextPos2_ = startPos2;
969     endTextView_ = startView2;
970     endTextPos_ = startPos2;
971     postModify(scroll);
972   }
973   
974   
975   /*package*/ void extendTextSelection(
976     int endView,
977     int endPos,
978     boolean scroll)
979   {
980     assert isTextSelection();
981     if (endView != endTextView_ || endPos != endTextPos_)
982     {
983       preModify();
984       endTextView_ = endView;
985       endTextPos_ = endPos;
986       postModify(scroll);
987     }
988   }
989   
990   
991   /*package*/ void setChordSelection(
992     int chordGroup,
993     int startView,
994     int startPos,
995     int endView,
996     int endPos,
997     boolean scroll)
998   {
999     assert containerBlock_ != -1;
1000    assert containerLine_ != -1;
1001    preModify();
1002    containerChordGroup_ = chordGroup;
1003    startTextView_ = startView;
1004    startTextPos_ = startPos;
1005    startTextView2_ = startView;
1006    startTextPos2_ = startPos;
1007    endTextView_ = endView;
1008    endTextPos_ = endPos;
1009    postModify(scroll);
1010  }
1011  
1012  
1013  /*package*/ void startChordSelection(
1014    int chordGroup,
1015    int startView,
1016    int startPos,
1017    int startView2,
1018    int startPos2,
1019    boolean scroll)
1020  {
1021    assert containerBlock_ != -1;
1022    assert containerLine_ != -1;
1023    preModify();
1024    containerChordGroup_ = chordGroup;
1025    startTextView_ = startView;
1026    startTextPos_ = startPos;
1027    startTextView2_ = startView2;
1028    startTextPos2_ = startPos2;
1029    endTextView_ = startView2;
1030    endTextPos_ = startPos2;
1031    postModify(scroll);
1032  }
1033  
1034  
1035  /*package*/ void extendChordSelection(
1036    int endView,
1037    int endPos,
1038    boolean scroll)
1039  {
1040    assert isChordSelection();
1041    if (endView != endTextView_ || endPos != endTextPos_)
1042    {
1043      preModify();
1044      endTextView_ = endView;
1045      endTextPos_ = endPos;
1046      postModify(scroll);
1047    }
1048  }
1049  
1050  
1051  /*package*/ void setLastX(
1052    float x)
1053  {
1054    lastX_ = new Float(x);
1055  }
1056  
1057  
1058  public String toString()
1059  {
1060    if (startBlock_ != -1)
1061    {
1062      return "block: s1="+startBlock_+" s2="+startBlock2_+" e="+endBlock_;
1063    }
1064    if (startLine_ != -1)
1065    {
1066      return "line: b="+containerBlock_+" s1="+startLine_+" s2="+startLine2_+" e="+endLine_;
1067    }
1068    if (startTextView_ == -1)
1069    {
1070      return "empty selection";
1071    }
1072    if (containerChordGroup_ != -1)
1073    {
1074      return "chords: b="+containerBlock_+" l="+containerLine_+" g="+containerChordGroup_+" sv1="+startTextView_+" sp1="+startTextPos_+
1075        " sv2="+startTextView2_+" sp2="+startTextPos2_+" ev="+endTextView_+" ep="+endTextPos_;
1076    }
1077    else
1078    {
1079      return "text: b="+containerBlock_+" l="+containerLine_+" sv1="+startTextView_+" sp1="+startTextPos_+
1080        " sv2="+startTextView2_+" sp2="+startTextPos2_+" ev="+endTextView_+" ep="+endTextPos_;
1081    }
1082  }
1083}