[jsword-svn] jsword/java/jsword/org/crosswire/jsword/passage s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Sat Jun 4 20:46:53 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage
In directory www.crosswire.org:/tmp/cvs-serv6657/java/jsword/org/crosswire/jsword/passage
Modified Files:
AbstractPassage.java RestrictionType.java BitwisePassage.java
VerseRange.java PassageTally.java
Log Message:
Improved blurring.
Index: AbstractPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/AbstractPassage.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** AbstractPassage.java 17 May 2005 00:43:15 -0000 1.45
--- AbstractPassage.java 5 Jun 2005 03:46:50 -0000 1.46
***************
*** 1212,1216 ****
* Do we restrict ranges to not crossing chapter boundries
*/
! private RestrictionType restrict = RestrictionType.NONE;
}
--- 1212,1216 ----
* Do we restrict ranges to not crossing chapter boundries
*/
! private RestrictionType restrict;
}
Index: BitwisePassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/BitwisePassage.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** BitwisePassage.java 17 May 2005 00:43:15 -0000 1.25
--- BitwisePassage.java 5 Jun 2005 03:46:50 -0000 1.26
***************
*** 293,317 ****
public void blur(int verses, RestrictionType restrict)
{
optimizeWrites();
raiseNormalizeProtection();
- if (verses < 0)
- {
- throw new IllegalArgumentException(Msg.ERROR_BLUR.toString());
- }
-
if (!restrict.equals(RestrictionType.NONE))
{
! BitwisePassage temp = (BitwisePassage) this.clone();
! Iterator it = temp.rangeIterator(RestrictionType.NONE);
!
! while (it.hasNext())
! {
! VerseRange range = restrict.blur((VerseRange) it.next(), verses, verses);
! add(range);
! }
}
else
{
int versesInBible = BibleInfo.versesInBible();
BitSet newStore = new BitSet(versesInBible + 1);
--- 293,310 ----
public void blur(int verses, RestrictionType restrict)
{
+ assert verses > 0;
optimizeWrites();
raiseNormalizeProtection();
if (!restrict.equals(RestrictionType.NONE))
{
! super.blur(verses, restrict);
}
else
{
+ optimizeWrites();
+ raiseEventSuppresion();
+ raiseNormalizeProtection();
+
int versesInBible = BibleInfo.versesInBible();
BitSet newStore = new BitSet(versesInBible + 1);
***************
*** 329,336 ****
store = newStore;
- }
! lowerNormalizeProtection();
! fireIntervalAdded(this, null, null);
}
--- 322,332 ----
store = newStore;
! lowerNormalizeProtection();
! if (lowerEventSuppresionAndTest())
! {
! fireIntervalAdded(this, null, null);
! }
! }
}
Index: VerseRange.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/VerseRange.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** VerseRange.java 17 May 2005 00:43:15 -0000 1.42
--- VerseRange.java 5 Jun 2005 03:46:50 -0000 1.43
***************
*** 1040,1043 ****
--- 1040,1047 ----
public boolean contains(Key key)
{
+ if (key instanceof VerseRange)
+ {
+ return contains((VerseRange) key);
+ }
return false;
}
***************
*** 1103,1107 ****
public void blur(int by, RestrictionType restrict)
{
! throw new UnsupportedOperationException();
}
--- 1107,1114 ----
public void blur(int by, RestrictionType restrict)
{
! VerseRange newRange = restrict.blur(this, by, by);
! start = newRange.start;
! end = newRange.end;
! verseCount = newRange.verseCount;
}
Index: RestrictionType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/RestrictionType.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** RestrictionType.java 17 May 2005 00:43:15 -0000 1.8
--- RestrictionType.java 5 Jun 2005 03:46:50 -0000 1.9
***************
*** 86,131 ****
};
! /**
! * Blurring is restricted to the book.
! */
! public static final RestrictionType BOOK = new RestrictionType("BOOK") //$NON-NLS-1$
! {
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.RestrictionType#isSameScope(org.crosswire.jsword.passage.Verse, org.crosswire.jsword.passage.Verse)
! */
! public boolean isSameScope(Verse start, Verse end)
! {
! return start.isSameBook(end);
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.VerseRange, int, int)
! */
! public VerseRange blur(VerseRange range, int blurDown, int blurUp)
! {
! throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
! */
! public VerseRange blur(Verse verse, int blurDown, int blurUp)
! {
! throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
! */
! public VerseRange toRange(Verse verse, int count)
! {
! throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! }
!
! /**
! * Serialization ID
! */
! private static final long serialVersionUID = 3978142166633820472L;
! };
/**
--- 86,131 ----
};
! // /**
! // * Blurring is restricted to the book.
! // */
! // public static final RestrictionType BOOK = new RestrictionType("BOOK") //$NON-NLS-1$
! // {
! // /* (non-Javadoc)
! // * @see org.crosswire.jsword.passage.RestrictionType#isSameScope(org.crosswire.jsword.passage.Verse, org.crosswire.jsword.passage.Verse)
! // */
! // public boolean isSameScope(Verse start, Verse end)
! // {
! // return start.isSameBook(end);
! // }
! //
! // /* (non-Javadoc)
! // * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.VerseRange, int, int)
! // */
! // public VerseRange blur(VerseRange range, int blurDown, int blurUp)
! // {
! // throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! // }
! //
! // /* (non-Javadoc)
! // * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
! // */
! // public VerseRange blur(Verse verse, int blurDown, int blurUp)
! // {
! // throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! // }
! //
! // /* (non-Javadoc)
! // * @see org.crosswire.jsword.passage.RestrictionType#blur(org.crosswire.jsword.passage.Verse, int, int)
! // */
! // public VerseRange toRange(Verse verse, int count)
! // {
! // throw new IllegalArgumentException(Msg.RANGE_BLURBOOK.toString());
! // }
! //
! // /**
! // * Serialization ID
! // */
! // private static final long serialVersionUID = 3978142166633820472L;
! // };
/**
***************
*** 149,167 ****
try
{
! int startBook = range.getStart().getBook();
! int startChapter = range.getStart().getChapter();
! int startVerse = range.getStart().getVerse() - blurDown;
!
! int endBook = range.getEnd().getBook();
! int endChapter = range.getEnd().getChapter();
! int endVerse = range.getEnd().getVerse() + blurUp;
startVerse = Math.max(startVerse, 1);
endVerse = Math.min(endVerse, BibleInfo.versesInChapter(endBook, endChapter));
! Verse start = new Verse(startBook, startChapter, startVerse);
! Verse end = new Verse(endBook, endChapter, endVerse);
! return new VerseRange(start, end);
}
catch (NoSuchVerseException ex)
--- 149,168 ----
try
{
+ Verse start = range.getStart();
+ int startBook = start.getBook();
+ int startChapter = start.getChapter();
+ int startVerse = start.getVerse() - blurDown;
! Verse end = range.getEnd();
! int endBook = end.getBook();
! int endChapter = end.getChapter();
! int endVerse = end.getVerse() + blurUp;
startVerse = Math.max(startVerse, 1);
endVerse = Math.min(endVerse, BibleInfo.versesInChapter(endBook, endChapter));
! Verse newStart = new Verse(startBook, startChapter, startVerse);
! Verse newEnd = new Verse(endBook, endChapter, endVerse);
! return new VerseRange(newStart, newEnd);
}
catch (NoSuchVerseException ex)
***************
*** 362,366 ****
if (defaultBlurRestriction == null)
{
! defaultBlurRestriction = RestrictionType.CHAPTER;
}
return defaultBlurRestriction;
--- 363,367 ----
if (defaultBlurRestriction == null)
{
! defaultBlurRestriction = RestrictionType.NONE;
}
return defaultBlurRestriction;
***************
*** 389,394 ****
{
NONE,
- BOOK,
CHAPTER,
};
}
--- 390,395 ----
{
NONE,
CHAPTER,
+ // BOOK,
};
}
Index: PassageTally.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/PassageTally.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** PassageTally.java 17 May 2005 00:43:15 -0000 1.38
--- PassageTally.java 5 Jun 2005 03:46:50 -0000 1.39
***************
*** 634,646 ****
public void blur(int verses, RestrictionType restrict)
{
! optimizeWrites();
raiseNormalizeProtection();
- if (verses < 0)
- {
- throw new IllegalArgumentException(Msg.ERROR_BLUR.toString());
- }
-
if (!restrict.equals(RestrictionType.NONE))
{
--- 634,643 ----
public void blur(int verses, RestrictionType restrict)
{
! assert verses > 0;
+ optimizeWrites();
+ raiseEventSuppresion();
raiseNormalizeProtection();
if (!restrict.equals(RestrictionType.NONE))
{
***************
*** 708,712 ****
lowerNormalizeProtection();
! fireIntervalAdded(this, null, null);
}
--- 705,712 ----
lowerNormalizeProtection();
! if (lowerEventSuppresionAndTest())
! {
! fireIntervalAdded(this, null, null);
! }
}
More information about the jsword-svn
mailing list