harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r479418 [38/43] - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common: javax/swing/ javax/swing/border/ javax/swing/colorchooser/ javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/ javax/swing/plaf/basic/ j...
Date Sun, 26 Nov 2006 20:15:55 GMT
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java Sun Nov 26 12:15:43 2006
@@ -26,7 +26,6 @@
 import java.awt.Rectangle;
 import java.text.BreakIterator;
 import java.text.CharacterIterator;
-
 import javax.swing.JFrame;
 import javax.swing.JTextArea;
 import javax.swing.JTextField;
@@ -36,32 +35,31 @@
 public class UtilitiesTest extends SwingTestCase {
     JTextComponent textComponent;
 
-    TabExp         te   = new TabExp();
+    TabExp te = new TabExp();
 
-    JFrame         jf;
+    JFrame jf;
 
     //not implemented
     //JEditorPane jtp;
     //not implemented
     //JTextPane jtp;
+    JTextArea jta;
 
-    JTextArea      jta;
-
-    JTextField     jtf;
+    JTextField jtf;
 
-    Document       doc_jta;
+    Document doc_jta;
 
-    Document       doc_jtp;
+    Document doc_jtp;
 
-    Document       doc_jtf;
+    Document doc_jtf;
 
-    String         sLTR = "aaaa";
+    String sLTR = "aaaa";
 
-    String         sRTL = "\u05dc" + "\u05dc" + "\u05dc" + "\u05dc";
+    String sRTL = "\u05dc" + "\u05dc" + "\u05dc" + "\u05dc";
 
-    boolean        bWasException;
+    boolean bWasException;
 
-    String         message;
+    String message;
 
     class TabExp implements TabExpander {
         public float nextTabStop(final float f, final int i) {
@@ -70,19 +68,16 @@
         }
     }
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         timeoutDelay = 10 * DEFAULT_TIMEOUT_DELAY;
-
         bWasException = false;
         message = null;
-
-        String content = sRTL + "\t" + sLTR + "\t" + sRTL + "\t\t" + sLTR
-                + "\n" + sLTR + "\t " + sLTR + " \t " + sLTR + sRTL + sRTL
-                + sRTL + sRTL + "\n" + sRTL + " " + sRTL + "  " + sRTL + "\n"
-                + sRTL + " " + sRTL + "; " + sRTL + "\n" + sRTL + ";" + sLTR
-                + " \t" + sRTL + "\t" + sRTL + " " + sRTL + ",";
-
+        String content = sRTL + "\t" + sLTR + "\t" + sRTL + "\t\t" + sLTR + "\n" + sLTR + "\t "
+                + sLTR + " \t " + sLTR + sRTL + sRTL + sRTL + sRTL + "\n" + sRTL + " " + sRTL
+                + "  " + sRTL + "\n" + sRTL + " " + sRTL + "; " + sRTL + "\n" + sRTL + ";"
+                + sLTR + " \t" + sRTL + "\t" + sRTL + " " + sRTL + ",";
         jf = new JFrame();
         jta = new JTextArea(content);
         jtf = new JTextField(content);
@@ -92,7 +87,6 @@
         //doc_jtp = jtp.getDocument();
         doc_jtf = jtf.getDocument();
         //setContent();
-
         jf.getContentPane().setLayout(new GridLayout(2, 2));
         jf.getContentPane().add(jta);
         jf.getContentPane().add(jtf);
@@ -102,13 +96,11 @@
     }
 
     protected void setContent() {
-        String str[] = {"Draws the given text, expanding any tabs",
+        String str[] = { "Draws the given text, expanding any tabs",
                 "that are contained using the given tab expansion technique",
                 "Determines the width of the given segment of text taking",
-                "Draws the given text, expanding any tabs",};
-
+                "Draws the given text, expanding any tabs", };
         SimpleAttributeSet[] attrs = new SimpleAttributeSet[4];
-
         attrs[0] = new SimpleAttributeSet();
         StyleConstants.setFontFamily(attrs[0], "SansSerif");
         StyleConstants.setFontSize(attrs[0], 16);
@@ -118,18 +110,16 @@
         StyleConstants.setItalic(attrs[2], true);
         attrs[3] = new SimpleAttributeSet(attrs[0]);
         StyleConstants.setFontSize(attrs[3], 20);
-
         try {
             for (int i = 0; i < str.length; i++) {
-                doc_jtp.insertString(doc_jtp.getLength(), str[i] + "\n",
-                                     attrs[i]);
+                doc_jtp.insertString(doc_jtp.getLength(), str[i] + "\n", attrs[i]);
             }
         } catch (BadLocationException ble) {
             System.err.println("Error");
         }
-
     }
 
+    @Override
     protected void tearDown() throws Exception {
         jf.dispose();
         super.tearDown();
@@ -149,47 +139,43 @@
         message = null;
     }
 
-    int getTabbedTextOffset(final Segment s, final FontMetrics fm, final int start, final int end,
-                            final TabExpander t, final int pos) {
+    int getTabbedTextOffset(final Segment s, final FontMetrics fm, final int start,
+            final int end, final TabExpander t, final int pos) {
         int res = start;
-        int width = end - start;
-        String str = "";
         boolean lastTab = true;
         int ret = 0;
         int tmp1 = 0;
-        int tmp2 = 0;
         //TODO end < start
         for (char c = s.first(); c != CharacterIterator.DONE; c = s.next()) {
-            if (c == '\t' && t == null)
+            if (c == '\t' && t == null) {
                 c = ' ';
+            }
             if (c == '\t') {
                 tmp1 = res;
-                res = (int)t.nextTabStop(res, s.getIndex() + pos
-                        - s.getBeginIndex());// + s.getIndex());
+                res = (int) t.nextTabStop(res, s.getIndex() + pos - s.getBeginIndex());// + s.getIndex());
                 lastTab = true;
-                str = "";
             } else {
                 res += fm.charWidth(c);
                 lastTab = false;
             }
-
             int diff = (lastTab) ? (res - tmp1) : (fm.charWidth(c));
             int tail = (diff / 2) + 1;
-            if (res < end + tail)
+            if (res < end + tail) {
                 ret++;
-            else
+            } else {
                 return ret;
+            }
         }
         return ret;
     }
 
-    int getTabbedTextWidth(final Segment s, final FontMetrics fm, final int x, final TabExpander t,
-                           final int pos) {
+    int getTabbedTextWidth(final Segment s, final FontMetrics fm, final int x,
+            final TabExpander t, final int pos) {
         return getTabbedTextEnd(s, fm, x, t, pos) - x;
     }
 
-    int getTabbedTextEnd(final Segment s, final FontMetrics fm, final int x, final TabExpander t,
-                         final int pos) {
+    int getTabbedTextEnd(final Segment s, final FontMetrics fm, final int x,
+            final TabExpander t, final int pos) {
         int res = x;
         String str = "";
         boolean isNullTabExpander = (t == null);
@@ -198,8 +184,7 @@
         for (char c = s.first(); c != CharacterIterator.DONE; c = s.next()) {
             isTab = (c == '\t');
             if (isTab && !isNullTabExpander) {
-                res = (int)t.nextTabStop(fm.stringWidth(str) + res, s
-                        .getIndex()
+                res = (int) t.nextTabStop(fm.stringWidth(str) + res, s.getIndex()
                         + segmentOffset);
                 str = "";
             } else {
@@ -227,19 +212,14 @@
                     assertTrue("Unexpected Exception: " + e.getMessage(), false);
                 }
                 FontMetrics fm = g.getFontMetrics();
-                assertEquals(Utilities.drawTabbedText(seg, 23, 24, g, te, j),
-                             getTabbedTextEnd(seg, fm, 23, te, j));
-
+                assertEquals(Utilities.drawTabbedText(seg, 23, 24, g, te, j), getTabbedTextEnd(
+                        seg, fm, 23, te, j));
                 assertEquals(Utilities.drawTabbedText(seg, 23, 24, g, null, j),
-                             getTabbedTextEnd(seg, fm, 23, null, j));
-
+                        getTabbedTextEnd(seg, fm, 23, null, j));
                 assertEquals(Utilities.drawTabbedText(seg, 23, 24, g, te, 100),
-                             getTabbedTextEnd(seg, fm, 23, te, 100));
-
-                assertEquals(Utilities
-                        .drawTabbedText(seg, 23, 24, g, null, 100),
-                             getTabbedTextEnd(seg, fm, 23, null, 100));
-
+                        getTabbedTextEnd(seg, fm, 23, te, 100));
+                assertEquals(Utilities.drawTabbedText(seg, 23, 24, g, null, 100),
+                        getTabbedTextEnd(seg, fm, 23, null, 100));
             }
         }
     }
@@ -268,16 +248,13 @@
                     assertTrue("Unexpected Exception: " + e.getMessage(), false);
                 }
                 assertEquals(Utilities.getTabbedTextWidth(seg, fm, 23, te, j),
-                             getTabbedTextWidth(seg, fm, 23, te, j));
-                assertEquals(
-                             Utilities.getTabbedTextWidth(seg, fm, 23, null, j),
-                             getTabbedTextWidth(seg, fm, 23, null, j));
-                assertEquals(
-                             Utilities.getTabbedTextWidth(seg, fm, 23, te, 100),
-                             getTabbedTextWidth(seg, fm, 23, te, 100));
-                assertEquals(Utilities.getTabbedTextWidth(seg, fm, 23, null,
-                                                          100),
-                             getTabbedTextWidth(seg, fm, 23, null, 100));
+                        getTabbedTextWidth(seg, fm, 23, te, j));
+                assertEquals(Utilities.getTabbedTextWidth(seg, fm, 23, null, j),
+                        getTabbedTextWidth(seg, fm, 23, null, j));
+                assertEquals(Utilities.getTabbedTextWidth(seg, fm, 23, te, 100),
+                        getTabbedTextWidth(seg, fm, 23, te, 100));
+                assertEquals(Utilities.getTabbedTextWidth(seg, fm, 23, null, 100),
+                        getTabbedTextWidth(seg, fm, 23, null, 100));
             }
         }
     }
@@ -288,8 +265,8 @@
         //getTabbedTextWidthTest(jtp);
     }
 
-    int getTabbedTextOffsetRound(final Segment s, final FontMetrics fm, final int start, final int end,
-                                 final TabExpander t, final int pos, final boolean round) {
+    int getTabbedTextOffsetRound(final Segment s, final FontMetrics fm, final int start,
+            final int end, final TabExpander t, final int pos, final boolean round) {
         String str = "";
         int segmentOffset = pos - s.getBeginIndex();
         boolean isTab = false;
@@ -301,8 +278,7 @@
         for (char c = s.first(); c != CharacterIterator.DONE; c = s.next()) {
             isTab = (c == '\t');
             if (isTab && !isNullTabExpander) {
-                tabEnd = (int)t.nextTabStop(currentEnd, s.getIndex()
-                        + segmentOffset);
+                tabEnd = (int) t.nextTabStop(currentEnd, s.getIndex() + segmentOffset);
                 str = "";
             } else {
                 str += (isTab) ? ' ' : c;
@@ -310,7 +286,6 @@
             }
             currentEnd = isTab ? tabEnd : (tabEnd + fm.stringWidth(str));
             int delta = (round) ? (currentEnd - prevEnd) / 2 : 0;
-
             if (currentEnd > end + delta) {
                 break;
             }
@@ -323,9 +298,9 @@
     void getTabbedTextOffsetRoundTest_BoundaryCases(final JTextComponent c) {
         Document doc = c.getDocument();
         Graphics g = c.getGraphics();
+        assertNotNull(g);
         Element root = doc.getDefaultRootElement();
         Segment seg = new Segment();
-
         for (int i = 0; i < root.getElementCount(); i++) {
             Element currentElem = root.getElement(i);
             int start = currentElem.getStartOffset();
@@ -336,33 +311,20 @@
                 assertTrue("Unexpected Exception: " + e.getMessage(), false);
             }
             int textOffset = start + 9;
-
             FontMetrics fm = getFontMetrics(c.getFont(), 10);
             int textWidth = getTabbedTextWidth(seg, fm, 23, te, textOffset);
-            for (int k = -3; k < textWidth + 4; k = (k == 0) ? k = textWidth + 1
-                    : k + 1) {
+            for (int k = -3; k < textWidth + 4; k = (k == 0) ? k = textWidth + 1 : k + 1) {
                 int target = 23 + k;
                 int offset = (k <= 0) ? 0 : seg.count;
-                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23,
-                                                                   target, te,
-                                                                   textOffset,
-                                                                   false));
-                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23,
-                                                                   target, te,
-                                                                   textOffset,
-                                                                   true));
-                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23,
-                                                                   target,
-                                                                   null,
-                                                                   textOffset,
-                                                                   false));
-                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23,
-                                                                   target,
-                                                                   null,
-                                                                   textOffset,
-                                                                   true));
+                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23, target, te,
+                        textOffset, false));
+                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23, target, te,
+                        textOffset, true));
+                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23, target, null,
+                        textOffset, false));
+                assertEquals(offset, Utilities.getTabbedTextOffset(seg, fm, 23, target, null,
+                        textOffset, true));
             }
-
         }
     }
 
@@ -378,7 +340,6 @@
         Element root = doc.getDefaultRootElement();
         Segment seg = new Segment();
         FontMetrics fm = g.getFontMetrics();
-
         for (int i = 0; i < root.getElementCount(); i++) {
             Element currentElem = root.getElement(i);
             int start = currentElem.getStartOffset();
@@ -388,22 +349,15 @@
             } catch (BadLocationException e) {
                 assertTrue("Unexpected Exception: " + e.getMessage(), false);
             }
-
             int offset = start + 8;
-            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te,
-                                                         offset);
+            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te, offset);
             for (int k = 0; k < textWidth; k++) {
                 int target = 23 + k;
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te,
-                                                      offset, false), Utilities
-                        .getTabbedTextOffset(seg, fm, 23, target, te, offset,
-                                             false));
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te,
-                                                      offset, true), Utilities
-                        .getTabbedTextOffset(seg, fm, 23, target, te, offset,
-                                             true));
+                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te, offset, false),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, te, offset, false));
+                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te, offset, true),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, te, offset, true));
             }
-
         }
     }
 
@@ -419,7 +373,6 @@
         FontMetrics fm = g.getFontMetrics();
         Element root = doc.getDefaultRootElement();
         Segment seg = new Segment();
-
         for (int i = 0; i < root.getElementCount(); i++) {
             Element currentElem = root.getElement(i);
             int start = currentElem.getStartOffset();
@@ -430,21 +383,15 @@
             } catch (BadLocationException e) {
                 assertTrue("Unexpected Exception: " + e.getMessage(), false);
             }
-
-            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te,
-                                                         offset);
+            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te, offset);
             for (int k = 0; k < textWidth; k += 100) {
                 int target = 23 + k;
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target,
-                                                      null, offset, false),
-                             Utilities.getTabbedTextOffset(seg, fm, 23, target,
-                                                           null, offset, false));
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target,
-                                                      null, offset, true),
-                             Utilities.getTabbedTextOffset(seg, fm, 23, target,
-                                                           null, offset, true));
+                assertEquals(
+                        getTabbedTextOffsetRound(seg, fm, 23, target, null, offset, false),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, null, offset, false));
+                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, null, offset, true),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, null, offset, true));
             }
-
         }
     }
 
@@ -460,7 +407,6 @@
         Element root = doc.getDefaultRootElement();
         Segment seg = new Segment();
         FontMetrics fm = g.getFontMetrics();
-
         for (int i = 0; i < root.getElementCount(); i++) {
             Element currentElem = root.getElement(i);
             int start = currentElem.getStartOffset();
@@ -471,17 +417,13 @@
                 assertTrue("Unexpected Exception: " + e.getMessage(), false);
             }
             int offset = start + 6;
-            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te,
-                                                         offset);
+            int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te, offset);
             for (int k = -3; k < textWidth + 4; k++) {
                 int target = 23 + k;
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te,
-                                                      offset, true), Utilities
-                        .getTabbedTextOffset(seg, fm, 23, target, te, offset));
-                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target,
-                                                      null, offset, true),
-                             Utilities.getTabbedTextOffset(seg, fm, 23, target,
-                                                           null, offset));
+                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, te, offset, true),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, te, offset));
+                assertEquals(getTabbedTextOffsetRound(seg, fm, 23, target, null, offset, true),
+                        Utilities.getTabbedTextOffset(seg, fm, 23, target, null, offset));
             }
         }
     }
@@ -493,21 +435,17 @@
     }
 
     int getBreakLocation(final Segment s, final FontMetrics fm, final int start, final int end,
-                         final TabExpander t, final int pos) {
+            final TabExpander t, final int pos) {
         int offset = s.offset;
-        int index = Utilities.getTabbedTextOffset(s, fm, start, end, t, pos,
-                false);
-
-        int fullIndex = offset +  index;
-
+        int index = Utilities.getTabbedTextOffset(s, fm, start, end, t, pos, false);
+        int fullIndex = offset + index;
         BreakIterator bi = BreakIterator.getWordInstance();
         bi.setText(s);
         if (bi.last() <= fullIndex) {
             return bi.last() - offset;
         }
         if (bi.isBoundary(fullIndex)) {
-            return Character.isWhitespace(s.array[fullIndex])
-                   ? index + 1 : index;
+            return Character.isWhitespace(s.array[fullIndex]) ? index + 1 : index;
         }
         int prev = bi.preceding(fullIndex);
         if (prev == bi.first()) {
@@ -516,7 +454,6 @@
         return prev - offset;
     }
 
-
     void getBreakLocationTest(final JTextComponent c) {
         Document doc = c.getDocument();
         Graphics g = c.getGraphics();
@@ -527,25 +464,20 @@
             Element currentElem = root.getElement(i);
             int start = currentElem.getStartOffset();
             int end = currentElem.getEndOffset();
-            for (int j = start; j < Math.min(start + 10,end); j++) {
+            for (int j = start; j < Math.min(start + 10, end); j++) {
                 try {
                     doc.getText(start, (end - start), seg);
                 } catch (BadLocationException e) {
                     assertTrue("Unexpected Exception: " + e.getMessage(), false);
                 }
-
-                int textWidth = Utilities
-                        .getTabbedTextWidth(seg, fm, 23, te, j);
+                int textWidth = Utilities.getTabbedTextWidth(seg, fm, 23, te, j);
                 for (int k = 0; k < textWidth; k++) {
                     int target = 23 + k;
                     //TODO This test have to fail
-
-                    assertEquals(Utilities.getBreakLocation(seg, fm, 23,
-                                                            target, te, j),
-                                 getBreakLocation(seg, fm, 23, target, te, j));
-                    assertEquals(Utilities.getBreakLocation(seg, fm, 23,
-                                                            target, null, j),
-                                 getBreakLocation(seg, fm, 23, target, null, j));
+                    assertEquals(Utilities.getBreakLocation(seg, fm, 23, target, te, j),
+                            getBreakLocation(seg, fm, 23, target, te, j));
+                    assertEquals(Utilities.getBreakLocation(seg, fm, 23, target, null, j),
+                            getBreakLocation(seg, fm, 23, target, null, j));
                 }
             }
         }
@@ -553,24 +485,20 @@
 
     public void testGetBreakLocation() {
         if (isHarmony()) {
-           getBreakLocationTest(jta);
+            getBreakLocationTest(jta);
         }
     }
 
     private void getParagraphElementTest(final JTextComponent c) {
-        AbstractDocument ad = (AbstractDocument)c.getDocument();
+        AbstractDocument ad = (AbstractDocument) c.getDocument();
         if (ad instanceof PlainDocument) {
             assertNull(Utilities.getParagraphElement(c, 5000));
             assertNull(Utilities.getParagraphElement(c, -5000));
         } else {
-            assertEquals(ad.getParagraphElement(5000), Utilities
-                    .getParagraphElement(c, 5000));
-            assertEquals(ad.getParagraphElement(-5000), Utilities
-                    .getParagraphElement(c, -5000));
+            assertEquals(ad.getParagraphElement(5000), Utilities.getParagraphElement(c, 5000));
+            assertEquals(ad.getParagraphElement(-5000), Utilities.getParagraphElement(c, -5000));
         }
-
         Element rootElement = ad.getDefaultRootElement();
-
         for (int i = 0; i < rootElement.getElementCount(); i++) {
             Element elem = rootElement.getElement(i);
             int start = elem.getStartOffset();
@@ -580,7 +508,6 @@
                 assertEquals(elem, ad.getParagraphElement(j));
             }
         }
-
     }
 
     public void testGetParagraphElement() {
@@ -592,13 +519,13 @@
     int getPositionAbove(final JTextComponent c, final int p, final int x)
             throws BadLocationException {
         int p0 = Utilities.getRowStart(c, p);
-        if (p0 == 0)
+        if (p0 == 0) {
             return -1;
+        }
         int end = p0 - 1;
         int diff = Integer.MAX_VALUE;
         int offset = 0;
         int start = Utilities.getRowStart(c, end);
-
         for (int i = start; i <= end; i++) {
             Rectangle rect = c.modelToView(i);
             assertNotNull(rect);
@@ -615,13 +542,13 @@
             throws BadLocationException {
         int p0 = Utilities.getRowEnd(c, p);
         int length = c.getDocument().getLength();
-        if (p0 == length)
+        if (p0 == length) {
             return p;
+        }
         int start = p0 + 1;
         int diff = Integer.MAX_VALUE;
         int offset = 0;
         int end = Utilities.getRowEnd(c, start);
-
         for (int i = start; i <= end; i++) {
             Rectangle rect = c.modelToView(i);
             assertNotNull(rect);
@@ -635,7 +562,7 @@
     }
 
     void getPositionAboveBelowTest(final JTextComponent c) {
-        BasicTextUI ui = (BasicTextUI)c.getUI();
+        BasicTextUI ui = (BasicTextUI) c.getUI();
         Document doc = c.getDocument();
         int length = doc.getLength();
         for (int i = 0; i < length; i++) {
@@ -643,29 +570,22 @@
             int utilAbove1 = 0;
             int utilBelow = 0;
             int utilBelow1 = 0;
-
             int utilAboveT = 0;
             int utilAbove1T = 0;
             int utilBelowT = 0;
             int utilBelow1T = 0;
-
             int appendix = 23;
             Rectangle rect = null;
             try {
                 rect = ui.modelToView(c, i);
             } catch (BadLocationException e) {
             }
-
             assertNotNull(rect);
-
             try {
                 utilBelow = Utilities.getPositionBelow(c, i, rect.x);
                 utilBelowT = getPositionBelow(c, i, rect.x);
-                utilBelow1 = Utilities
-                        .getPositionBelow(c, i, rect.x + appendix);
-                utilBelow1T = Utilities.getPositionBelow(c, i, rect.x
-                        + appendix);
-
+                utilBelow1 = Utilities.getPositionBelow(c, i, rect.x + appendix);
+                utilBelow1T = Utilities.getPositionBelow(c, i, rect.x + appendix);
             } catch (BadLocationException e) {
                 assertFalse("Unexpected exception: " + e.getMessage(), true);
             }
@@ -674,7 +594,6 @@
             assertEquals(utilBelow1, utilBelow1T);
             assertEquals(utilBelow, utilBelowT);
         }
-
         try {
             Utilities.getPositionAbove(c, -10, 100);
         } catch (BadLocationException e) {
@@ -689,7 +608,6 @@
             bWasException = true;
         }
         checkWasException("Position not represented by view");
-
         try {
             Utilities.getPositionBelow(c, -10, 100);
         } catch (BadLocationException e) {
@@ -704,7 +622,6 @@
             bWasException = true;
         }
         checkWasException("Position not represented by view");
-
     }
 
     public void testGetPositionAboveBelow() {
@@ -714,22 +631,20 @@
     }
 
     void getWordStartTest(final JTextComponent c) {
-        AbstractDocument ad = (AbstractDocument)c.getDocument();
+        AbstractDocument ad = (AbstractDocument) c.getDocument();
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = ad.getLength();
         try {
             bi.setText(ad.getText(0, ad.getLength()));
         } catch (BadLocationException e) {
         }
-
         int iteratorWordStart = 0;
         bi.first();
-
         for (int i = 0; i < length; i++) {
             int utilitiesWordStart = 0;
-            if (i < length - 1)
+            if (i < length - 1) {
                 iteratorWordStart = bi.preceding(i + 1);
-            else {
+            } else {
                 bi.last();
                 iteratorWordStart = bi.previous();
             }
@@ -739,7 +654,6 @@
             }
             assertEquals(iteratorWordStart, utilitiesWordStart);
         }
-
         /* According to spec */
         try {
             Utilities.getWordStart(c, length + 10);
@@ -748,7 +662,6 @@
             bWasException = true;
         }
         checkWasException("No word at " + (length + 10));
-
         try {
             Utilities.getWordStart(c, -1);
         } catch (BadLocationException e) {
@@ -766,14 +679,13 @@
     }
 
     void getWordEndTest(final JTextComponent c) {
-        AbstractDocument ad = (AbstractDocument)c.getDocument();
+        AbstractDocument ad = (AbstractDocument) c.getDocument();
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = ad.getLength();
         try {
             bi.setText(ad.getText(0, length));
         } catch (BadLocationException e) {
         }
-
         bi.first();
         for (int i = 0; i < length; i++) {
             int utilitiesWordEnd = 0;
@@ -791,9 +703,7 @@
             message = e.getMessage();
             bWasException = true;
         }
-
         checkWasException("No word at " + (length + 10));
-
         try {
             Utilities.getWordEnd(c, -1);
         } catch (BadLocationException e) {
@@ -812,10 +722,8 @@
 
     // may be in future...
     int getRowStart(final JTextComponent c, final int pos) throws BadLocationException {
-        int length = c.getDocument().getLength();
         Rectangle r = null;
         r = c.modelToView(pos);
-
         for (int i = pos; i >= 0; i--) {
             Rectangle tmp = null;
             tmp = c.modelToView(i);
@@ -828,8 +736,9 @@
 
     int getRowEnd(final JTextComponent c, final int pos) throws BadLocationException {
         int length = c.getDocument().getLength();
-        if (c instanceof JTextField)
+        if (c instanceof JTextField) {
             return length;
+        }
         Rectangle r = null;
         r = c.modelToView(pos);
         for (int i = pos; i <= length; i++) {
@@ -845,6 +754,7 @@
     void getRowStartEndTest(final JTextComponent c) throws Exception {
         Document doc = c.getDocument();
         View root = c.getUI().getRootView(c).getView(0);
+        assertNotNull(root);
         int length = doc.getLength();
         for (int i = 0; i < length; i++) {
             /*
@@ -866,16 +776,13 @@
             assertEquals(getRowEnd(c, i), utilitiesRowEnd);
             assertEquals(getRowStart(c, i), utilitiesRowStart);
         }
-
         try {
             Utilities.getRowStart(c, 5000);
         } catch (BadLocationException e) {
             bWasException = true;
             message = e.getMessage();
         }
-
         checkWasException("Position not represented by view");
-
         try {
             Utilities.getRowEnd(c, 5000);
         } catch (BadLocationException e) {
@@ -883,9 +790,7 @@
             message = e.getMessage();
         }
         ;
-
         checkWasException("Position not represented by view");
-
         try {
             Utilities.getRowStart(c, -10);
         } catch (BadLocationException e) {
@@ -902,32 +807,26 @@
         }
         ;
         checkWasException("Position not represented by view");
-
         textComponent = c;
         textComponent.setSize(0, 0);
-
         assertEquals(-1, Utilities.getRowStart(c, -20));
         assertEquals(-1, Utilities.getRowEnd(c, 5000));
         assertEquals(-1, Utilities.getRowStart(c, 5));
         assertEquals(-1, Utilities.getRowEnd(c, 6));
-
     }
 
     public void testGetRowStartEnd() {
-
         try {
             getRowStartEndTest(jta);
             //getRowStartEndTest(jtp);
-
             getRowStartEndTest(jtf);
-
         } catch (Exception e) {
             assertFalse("Unexpected exception", true);
         }
     }
 
     void getPreviousWordTest(final JTextComponent c) {
-        AbstractDocument ad = (AbstractDocument)c.getDocument();
+        AbstractDocument ad = (AbstractDocument) c.getDocument();
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = ad.getLength();
         String content = null;
@@ -936,7 +835,6 @@
             bi.setText(content);
         } catch (BadLocationException e) {
         }
-
         assertNotNull(content);
         bi.first();
         for (int i = 0; i < length; i++) {
@@ -945,18 +843,18 @@
             while (iteratorPrevWord > 0
                     && ((content.charAt(iteratorPrevWord) == ' ' || content
                             .charAt(iteratorPrevWord) == '\n') || content
-                            .charAt(iteratorPrevWord) == '\t'))
+                            .charAt(iteratorPrevWord) == '\t')) {
                 iteratorPrevWord = bi.preceding(iteratorPrevWord);
+            }
             try {
                 utilitiesPrevWord = Utilities.getPreviousWord(c, i);
             } catch (BadLocationException e) {
             }
-            if (iteratorPrevWord == -1)
+            if (iteratorPrevWord == -1) {
                 iteratorPrevWord = 0;
+            }
             assertEquals(iteratorPrevWord, utilitiesPrevWord);
-
         }
-
         try {
             Utilities.getPreviousWord(c, -1);
         } catch (BadLocationException e) {
@@ -980,7 +878,7 @@
     }
 
     void getNextWordTest(final JTextComponent c) {
-        AbstractDocument ad = (AbstractDocument)c.getDocument();
+        AbstractDocument ad = (AbstractDocument) c.getDocument();
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = ad.getLength();
         String content = null;
@@ -989,7 +887,6 @@
             bi.setText(content);
         } catch (BadLocationException e) {
         }
-
         assertNotNull(content);
         bi.first();
         for (int i = 0; i < length; i++) {
@@ -998,18 +895,18 @@
             while (iteratorNextWord < length
                     && ((content.charAt(iteratorNextWord) == ' ' || content
                             .charAt(iteratorNextWord) == '\n') || content
-                            .charAt(iteratorNextWord) == '\t'))
+                            .charAt(iteratorNextWord) == '\t')) {
                 iteratorNextWord = bi.following(iteratorNextWord);
+            }
             try {
                 utilitiesNextWord = Utilities.getNextWord(c, i);
             } catch (BadLocationException e) {
             }
-            if (iteratorNextWord == length)
+            if (iteratorNextWord == length) {
                 iteratorNextWord = 0;
-
+            }
             assertEquals(iteratorNextWord, utilitiesNextWord);
         }
-
         try {
             Utilities.getNextWord(c, length + 10);
         } catch (BadLocationException e) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewRTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewRTest.java Sun Nov 26 12:15:43 2006
@@ -25,7 +25,6 @@
 import java.awt.Shape;
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.swing.BasicSwingTestCase;
 import javax.swing.JTextArea;
 import javax.swing.event.DocumentEvent;
@@ -38,10 +37,9 @@
             final String name = element.getName();
             if (AbstractDocument.SectionElementName.equals(name)) {
                 return new BoxView(element, View.Y_AXIS) {
-                    protected void forwardUpdateToView(View view,
-                                                       DocumentEvent event,
-                                                       Shape shape,
-                                                       ViewFactory factory) {
+                    @Override
+                    protected void forwardUpdateToView(View view, DocumentEvent event,
+                            Shape shape, ViewFactory factory) {
                         viewsForwardedTo.add(view);
                         super.forwardUpdateToView(view, event, shape, factory);
                     }
@@ -58,14 +56,20 @@
     }
 
     private Document doc;
+
     private Element root;
+
     private View view;
+
     private DocumentEvent event;
 
     private static final ViewFactory factory = new Factory();
+
     private static final Shape shape = new Rectangle(5, 7, 452, 217);
-    private static final List viewsForwardedTo = new ArrayList();
 
+    private static final List<View> viewsForwardedTo = new ArrayList<View>();
+
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         doc = new DefaultStyledDocument();
@@ -99,30 +103,24 @@
     public void testInsertUpdate01() throws BadLocationException {
         MutableAttributeSet italic = new SimpleAttributeSet();
         StyleConstants.setItalic(italic, true);
-
         // Init the document structure
         doc.insertString(doc.getLength(), "plain", null);
         doc.insertString(doc.getLength(), "italic\n", italic);
-
         // Init the view hierarchy
-        view = (BoxView)factory.create(root);
-        ((CompositeView)view).loadChildren(factory);
+        view = factory.create(root);
+        ((CompositeView) view).loadChildren(factory);
         doc.addDocumentListener(this);
-
         // Perform the change tested against
         doc.insertString(doc.getLength(), "second", null);
-
         // Both paragraph elements will be modified,
         // but the section will not
         assertNotNull(event.getChange(root.getElement(0)));
         assertNotNull(event.getChange(root.getElement(1)));
         assertNull(event.getChange(root));
         viewsForwardedTo.clear();
-
         assertEquals(2, view.getViewCount());
         view.insertUpdate(event, shape, factory);
         assertEquals(2, view.getViewCount());
-
         assertEquals(2, viewsForwardedTo.size());
         assertSame(view.getView(0), viewsForwardedTo.get(0));
         assertSame(view.getView(1), viewsForwardedTo.get(1));
@@ -166,32 +164,26 @@
     public void testInsertUpdate02() throws BadLocationException {
         MutableAttributeSet italic = new SimpleAttributeSet();
         StyleConstants.setItalic(italic, true);
-
         // Init the document structure
         doc.insertString(doc.getLength(), "plain", null);
         doc.insertString(doc.getLength(), "italic\n", italic);
         doc.insertString(doc.getLength(), "second ", null);
         doc.insertString(doc.getLength(), "italic again", italic);
-
         // Init the view hierarchy
-        view = (BoxView)factory.create(root);
-        ((CompositeView)view).loadChildren(factory);
+        view = factory.create(root);
+        ((CompositeView) view).loadChildren(factory);
         doc.addDocumentListener(this);
-
         // Perform the change tested against
         doc.insertString(doc.getLength(), " & plain again\n", null);
-
         // Both paragraph elements will be modified,
         // but the section will not
         assertNotNull(event.getChange(root.getElement(1)));
         assertNull(event.getChange(root.getElement(2)));
         assertNotNull(event.getChange(root));
         viewsForwardedTo.clear();
-
         assertEquals(2, view.getViewCount());
         view.insertUpdate(event, shape, factory);
         assertEquals(3, view.getViewCount());
-
         assertEquals(1, viewsForwardedTo.size());
         assertSame(view.getView(1), viewsForwardedTo.get(0));
         viewsForwardedTo.clear();
@@ -203,27 +195,27 @@
         doc.insertString(0, "1\n\n\n\n", null);
         doc.addDocumentListener(this);
         doc.insertString(3, "\n2", null);
-
         final Marker marker = new Marker();
         final JTextArea area = new JTextArea(doc) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
             public void repaint() {
                 marker.setOccurred();
             }
         };
         view = new DisAbstractedView(root) {
+            @Override
             public Container getContainer() {
                 return area;
             }
         };
-
         assertEquals(0, view.getViewCount());
         assertNull(view.getParent());
-
         marker.reset();
         assertNotNull(event.getChange(root));
         view.updateLayout(event.getChange(root), event, shape);
         assertTrue(marker.isOccurred());
-
         marker.reset();
         view.updateLayout(null, event, shape);
         assertFalse(marker.isOccurred());

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTest.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -26,39 +25,37 @@
 import java.awt.Rectangle;
 import java.awt.Shape;
 import java.awt.geom.Rectangle2D;
-
 import javax.swing.JComponent;
 import javax.swing.text.Position.Bias;
-
 import junit.framework.TestCase;
 
 public class ViewTest extends TestCase {
-
     /**
      * View class that simply overrides abstract methods of View class.
      * No additional functionality is added.
      */
     public static class DisAbstractedView extends View {
-
         /**
          * Bounding shape. Used as the last parameter in
          * modelToView, viewToModel.
          */
         static final Rectangle2D bounding = new Rectangle(2, 2);
+
         /**
          * One of rectangles returned from modelToView.
          */
-        static final Rectangle2D r1       = new Rectangle(0, 0, 1, 1);
+        static final Rectangle2D r1 = new Rectangle(0, 0, 1, 1);
+
         /**
          * The second rectangle returned from modelToView.
          */
-        static final Rectangle2D r2       = new Rectangle(1, 1, 1, 1);
+        static final Rectangle2D r2 = new Rectangle(1, 1, 1, 1);
+
         /**
          *
          * @param element
          */
         static final Rectangle2D r3;
-
         static {
             r3 = new Rectangle2D.Double();
             Rectangle2D.union(r1, r2, r3);
@@ -68,35 +65,35 @@
             super(element);
         }
 
+        @Override
         public float getPreferredSpan(final int axis) {
             return axis == X_AXIS ? 1.27f : 2.53f;
         }
 
-        public Shape modelToView(final int pos, final Shape shape,
-                                 final Bias bias)
-            throws BadLocationException {
-
+        @Override
+        public Shape modelToView(final int pos, final Shape shape, final Bias bias)
+                throws BadLocationException {
             mtvBias = bias;
             if (pos == 1) {
                 return r2;
-            } else {
-                return r1;
             }
+            return r1;
         }
 
+        @Override
         public void paint(final Graphics g, final Shape shape) {
         }
 
+        @Override
         public int viewToModel(final float x, final float y, final Shape shape,
                 final Bias[] biasReturn) {
             // Save the parameters
-            viewToModelParams.x     = x;
-            viewToModelParams.y     = y;
+            viewToModelParams.x = x;
+            viewToModelParams.y = y;
             viewToModelParams.shape = shape;
-            viewToModelParams.bias  = biasReturn;
+            viewToModelParams.bias = biasReturn;
             return 0;
         }
-
     }
 
     private static class ResizableView extends DisAbstractedView {
@@ -104,6 +101,7 @@
             super(element);
         }
 
+        @Override
         public int getResizeWeight(final int axis) {
             return 1;
         }
@@ -115,50 +113,60 @@
      */
     private static class ViewToModelParams {
         public Bias[] bias;
-        public Shape  shape;
-        public float  x;
-        public float  y;
+
+        public Shape shape;
+
+        public float x;
+
+        public float y;
     }
 
     boolean containerGetGraphicsCalled;
 
     // Used in testPreferenceChanged
     boolean preferenceChangedCalledOnParent;
-    View    preferenceChangedChild;
+
+    View preferenceChangedChild;
+
     boolean revalidateCalled;
+
     boolean tooltipGetViewCalled;
 
     boolean tooltipGetViewIndexCalled;
+
     /**
      * Document shared among tests.
      */
     private Document doc;
+
     /**
      * Paragraph element shared among tests. This is the second line of
      * text in the document.
      */
-    private Element  line;
+    private Element line;
+
     /**
      * View under which tests are run.
      */
-    private View     view;
+    private View view;
+
     /**
      * Bias passes to modelToView method in the last call.
      */
-    private static Bias              mtvBias;
+    private static Bias mtvBias;
+
     /**
      * Parameters passed to viewToModel method.
      */
     private static ViewToModelParams viewToModelParams;
 
     public void testBreakView() {
-        assertSame(view, view.breakView(View.X_AXIS,
-                   line.getStartOffset() + 1, 4, 4));
+        assertSame(view, view.breakView(View.X_AXIS, line.getStartOffset() + 1, 4, 4));
     }
 
     public void testCreateFragment() {
-        assertSame(view, view.createFragment(line.getStartOffset() + 1,
-                                             line.getEndOffset() - 1));
+        assertSame(view, view
+                .createFragment(line.getStartOffset() + 1, line.getEndOffset() - 1));
     }
 
     public void testGetAlignment() {
@@ -179,19 +187,13 @@
         final float maxX = view.getMaximumSpan(View.X_AXIS); // = preferredSpan
         final float maxY = view.getMaximumSpan(View.Y_AXIS);
         assertEquals(maxX, view.getPreferredSpan(View.X_AXIS), 0.0001f);
-
         // By default return Bad, but...
-        assertEquals(View.BadBreakWeight,
-                     view.getBreakWeight(View.X_AXIS, 0.0f, maxX));
-        assertEquals(View.BadBreakWeight,
-                     view.getBreakWeight(View.Y_AXIS, 0.0f, maxY));
-
+        assertEquals(View.BadBreakWeight, view.getBreakWeight(View.X_AXIS, 0.0f, maxX));
+        assertEquals(View.BadBreakWeight, view.getBreakWeight(View.Y_AXIS, 0.0f, maxY));
         // ...but Good when length where to break is greater than
         // the length of the view
-        assertEquals(View.GoodBreakWeight,
-                     view.getBreakWeight(View.X_AXIS, 0.0f, maxX + 0.01f));
-        assertEquals(View.GoodBreakWeight,
-                     view.getBreakWeight(View.Y_AXIS, 0.0f, maxY + 0.01f));
+        assertEquals(View.GoodBreakWeight, view.getBreakWeight(View.X_AXIS, 0.0f, maxX + 0.01f));
+        assertEquals(View.GoodBreakWeight, view.getBreakWeight(View.Y_AXIS, 0.0f, maxY + 0.01f));
     }
 
     /**
@@ -199,22 +201,15 @@
      */
     public void testGetBreakWeight02() {
         view = new ResizableView(line);
-
         final float maxX = view.getPreferredSpan(View.X_AXIS);
         final float maxY = view.getPreferredSpan(View.Y_AXIS);
-
         // By default return Bad, but...
-        assertEquals(View.BadBreakWeight,
-                     view.getBreakWeight(View.X_AXIS, 0.0f, maxX));
-        assertEquals(View.BadBreakWeight,
-                     view.getBreakWeight(View.Y_AXIS, 0.0f, maxY));
-
+        assertEquals(View.BadBreakWeight, view.getBreakWeight(View.X_AXIS, 0.0f, maxX));
+        assertEquals(View.BadBreakWeight, view.getBreakWeight(View.Y_AXIS, 0.0f, maxY));
         // ...but Good when length where to break is greater than
         // the length of the view
-        assertEquals(View.GoodBreakWeight,
-                     view.getBreakWeight(View.X_AXIS, 0.0f, maxX + 0.01f));
-        assertEquals(View.GoodBreakWeight,
-                     view.getBreakWeight(View.Y_AXIS, 0.0f, maxY + 0.01f));
+        assertEquals(View.GoodBreakWeight, view.getBreakWeight(View.X_AXIS, 0.0f, maxX + 0.01f));
+        assertEquals(View.GoodBreakWeight, view.getBreakWeight(View.Y_AXIS, 0.0f, maxY + 0.01f));
     }
 
     public void testGetChildAllocation() {
@@ -243,17 +238,20 @@
     }
 
     public void testGetGraphics() {
-        view =
-            new DisAbstractedView(doc.getDefaultRootElement().getElement(0)) {
-                public Container getContainer() {
-                    return new JComponent() {
-                        public Graphics getGraphics() {
-                            containerGetGraphicsCalled = true;
-                            return null;
-                        }
-                    };
-                }
-            };
+        view = new DisAbstractedView(doc.getDefaultRootElement().getElement(0)) {
+            @Override
+            public Container getContainer() {
+                return new JComponent() {
+                    private static final long serialVersionUID = 1L;
+
+                    @Override
+                    public Graphics getGraphics() {
+                        containerGetGraphicsCalled = true;
+                        return null;
+                    }
+                };
+            }
+        };
         assertFalse(containerGetGraphicsCalled);
         assertNull(view.getGraphics());
         assertTrue(containerGetGraphicsCalled);
@@ -263,10 +261,10 @@
      * Tests <code>getMaximumSpan</code> with default view setup.
      */
     public void testGetMaximumSpan01() {
-        assertEquals(view.getPreferredSpan(View.X_AXIS),
-                     view.getMaximumSpan(View.X_AXIS), 0.000001f);
-        assertEquals(view.getPreferredSpan(View.Y_AXIS),
-                     view.getMaximumSpan(View.Y_AXIS), 0.000001f);
+        assertEquals(view.getPreferredSpan(View.X_AXIS), view.getMaximumSpan(View.X_AXIS),
+                0.000001f);
+        assertEquals(view.getPreferredSpan(View.Y_AXIS), view.getMaximumSpan(View.Y_AXIS),
+                0.000001f);
     }
 
     /**
@@ -274,21 +272,18 @@
      */
     public void testGetMaximumSpan02() {
         view = new ResizableView(line);
-
-        assertEquals(Integer.MAX_VALUE, view.getMaximumSpan(View.X_AXIS),
-                     0.000001f);
-        assertEquals(Integer.MAX_VALUE, view.getMaximumSpan(View.Y_AXIS),
-                     0.000001f);
+        assertEquals(Integer.MAX_VALUE, view.getMaximumSpan(View.X_AXIS), 0.000001f);
+        assertEquals(Integer.MAX_VALUE, view.getMaximumSpan(View.Y_AXIS), 0.000001f);
     }
 
     /**
      * Tests <code>getMinimumSpan</code> with default view setup.
      */
     public void testGetMinimumSpan01() {
-        assertEquals(view.getPreferredSpan(View.X_AXIS),
-                     view.getMinimumSpan(View.X_AXIS), 0.000001f);
-        assertEquals(view.getPreferredSpan(View.Y_AXIS),
-                     view.getMinimumSpan(View.Y_AXIS), 0.000001f);
+        assertEquals(view.getPreferredSpan(View.X_AXIS), view.getMinimumSpan(View.X_AXIS),
+                0.000001f);
+        assertEquals(view.getPreferredSpan(View.Y_AXIS), view.getMinimumSpan(View.Y_AXIS),
+                0.000001f);
     }
 
     /**
@@ -296,7 +291,6 @@
      */
     public void testGetMinimumSpan02() {
         view = new ResizableView(line);
-
         assertEquals(0.0f, view.getMinimumSpan(View.X_AXIS), 0.000001f);
         assertEquals(0.0f, view.getMinimumSpan(View.Y_AXIS), 0.000001f);
     }
@@ -320,18 +314,19 @@
     }
 
     public void testGetToolTipText() {
-        view =
-            new DisAbstractedView(doc.getDefaultRootElement().getElement(0)) {
-                public View getView(final int index) {
-                    tooltipGetViewCalled = true;
-                    return super.getView(index);
-                }
-                public int getViewIndex(final float x, final float y,
-                                        final Shape allocation) {
-                    tooltipGetViewIndexCalled = true;
-                    return super.getViewIndex(x, y, allocation);
-                }
-            };
+        view = new DisAbstractedView(doc.getDefaultRootElement().getElement(0)) {
+            @Override
+            public View getView(final int index) {
+                tooltipGetViewCalled = true;
+                return super.getView(index);
+            }
+
+            @Override
+            public int getViewIndex(final float x, final float y, final Shape allocation) {
+                tooltipGetViewIndexCalled = true;
+                return super.getViewIndex(x, y, allocation);
+            }
+        };
         assertNull(view.getToolTipText(0.0f, 0.0f, new Rectangle(2, 2)));
         // getToolTipText calls getViewIndex to get child at this location
         assertTrue(tooltipGetViewIndexCalled);
@@ -387,17 +382,16 @@
      * Class under test for
      * Shape modelToView(int, Position.Bias, int, Position.Bias, Shape)
      */
-    public void testModelToViewintBiasintBiasShape()
-        throws BadLocationException {
-
-        Shape a = view.modelToView(1, Bias.Forward, 2, Bias.Forward,
-                DisAbstractedView.bounding);
+    public void testModelToViewintBiasintBiasShape() throws BadLocationException {
+        Shape a = view
+                .modelToView(1, Bias.Forward, 2, Bias.Forward, DisAbstractedView.bounding);
         assertEquals(DisAbstractedView.r3, a);
     }
 
     /*
      * Class under test for Shape modelToView(int, Shape)
      */
+    @SuppressWarnings("deprecation")
     public void testModelToViewintShape() throws BadLocationException {
         Shape a = view.modelToView(0, DisAbstractedView.bounding);
         assertSame(DisAbstractedView.r1, a);
@@ -405,11 +399,13 @@
     }
 
     public void testPreferenceChanged() {
-        View parent =
-            new DisAbstractedView(doc.getDefaultRootElement()) {
-
+        View parent = new DisAbstractedView(doc.getDefaultRootElement()) {
+            @Override
             public Container getContainer() {
                 return new JTextComponent() {
+                    private static final long serialVersionUID = 1L;
+
+                    @Override
                     public void revalidate() {
                         revalidateCalled = true;
                         super.revalidate();
@@ -417,10 +413,10 @@
                 };
             }
 
-            public void preferenceChanged(final View child,
-                                          final boolean w, final boolean h) {
+            @Override
+            public void preferenceChanged(final View child, final boolean w, final boolean h) {
                 preferenceChangedCalledOnParent = true;
-                preferenceChangedChild          = child;
+                preferenceChangedChild = child;
                 // Assert the conditions are true
                 assertFalse(revalidateCalled);
                 assertNull(getParent());
@@ -431,12 +427,10 @@
             }
         };
         View child = getLine1View(doc);
-
         // Assert we get no exceptions or errors
         assertNull(view.getParent());
         view.preferenceChanged(child, true, false);
         assertFalse(preferenceChangedCalledOnParent);
-
         // Set parent and test, that parent gets called
         view.setParent(parent);
         view.preferenceChanged(child, true, false);
@@ -464,27 +458,24 @@
         View v = new DisAbstractedView(line);
         assertSame(line, v.getElement());
         assertSame(doc, v.getDocument());
-
         v = new DisAbstractedView(null);
         assertNull(v.getElement());
         try {
             assertNull(v.getDocument());
-
-            fail("This causes the exception 'cause element is used " +
-                 "to get the document");
-        } catch (NullPointerException e) { }
-
+            fail("This causes the exception 'cause element is used " + "to get the document");
+        } catch (NullPointerException e) {
+        }
         try {
             assertEquals(0, v.getStartOffset());
-
-            fail("This causes the exception 'cause element is used " +
-                 "to get the offset");
-        } catch (NullPointerException e) { }
+            fail("This causes the exception 'cause element is used " + "to get the offset");
+        } catch (NullPointerException e) {
+        }
     }
 
     /*
      * Class under test for int viewToModel(float, float, Shape)
      */
+    @SuppressWarnings("deprecation")
     public void testViewToModelfloatfloatShape() {
         Rectangle r = new Rectangle();
         view.viewToModel(0.1f, 0.2f, r);
@@ -498,13 +489,12 @@
     /*
      * @see TestCase#setUp()
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         doc = new PlainDocument();
         doc.insertString(0, "01234\nabcde", null);
         line = doc.getDefaultRootElement().getElement(1);
-
         view = new DisAbstractedView(line);
         viewToModelParams = new ViewToModelParams();
         mtvBias = null;
@@ -517,5 +507,4 @@
     static final View getLine1View(final Document doc) {
         return new DisAbstractedView(doc.getDefaultRootElement().getElement(0));
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTestHelpers.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTestHelpers.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTestHelpers.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/ViewTestHelpers.java Sun Nov 26 12:15:43 2006
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 /**
  * @author Alexey A. Ivanov
  * @version $Revision$
@@ -24,7 +23,6 @@
 import java.awt.Graphics;
 import java.awt.Rectangle;
 import java.awt.Shape;
-
 import javax.swing.event.DocumentEvent;
 import javax.swing.text.Position.Bias;
 
@@ -33,7 +31,6 @@
  *
  */
 public final class ViewTestHelpers {
-
     private ViewTestHelpers() {
     }
 
@@ -41,23 +38,27 @@
      * Default child view height.
      */
     private static final int HEIGHT = 16;
+
     /**
      * Default child view width.
      */
     private static final int WIDTH = 25;
+
     /**
      * Width multipliers to change the default width.
      */
-    private static final int[] WIDTH_MULTIPLIER  = new int[] {1, 3, 4, 2};
+    private static final int[] WIDTH_MULTIPLIER = new int[] { 1, 3, 4, 2 };
+
     /**
      * Height multipliers to change the default height.
      */
-    private static final int[] HEIGHT_MULTIPLIER = new int[] {2, 1, 3, 1};
+    private static final int[] HEIGHT_MULTIPLIER = new int[] { 2, 1, 3, 1 };
+
     /**
      * Alignments for children to change the default alignment (center = 0.5).
      */
-    private static final float[] ALIGNMENT =
-        new float[] {0.0f, 0.25f, 1.0f, 0.5f};
+    private static final float[] ALIGNMENT = new float[] { 0.0f, 0.25f, 1.0f, 0.5f };
+
     /**
      * One character width. It is used in model/view translations.
      */
@@ -71,9 +72,7 @@
      * @return the child width
      */
     public static int getWidth(final int id) {
-        return 0 <= id && id < WIDTH_MULTIPLIER.length
-               ? WIDTH * WIDTH_MULTIPLIER[id]
-               : WIDTH;
+        return 0 <= id && id < WIDTH_MULTIPLIER.length ? WIDTH * WIDTH_MULTIPLIER[id] : WIDTH;
     }
 
     /**
@@ -84,9 +83,8 @@
      * @return the child height
      */
     public static int getHeight(final int id) {
-        return 0 <= id && id < HEIGHT_MULTIPLIER.length
-               ? HEIGHT * HEIGHT_MULTIPLIER[id]
-               : HEIGHT;
+        return 0 <= id && id < HEIGHT_MULTIPLIER.length ? HEIGHT * HEIGHT_MULTIPLIER[id]
+                : HEIGHT;
     }
 
     /**
@@ -106,7 +104,6 @@
      * the behavior is predictable.
      */
     public static class ChildView extends View {
-
         private final int id;
 
         public ChildView(final Element element, final int ID) {
@@ -114,6 +111,7 @@
             id = ID;
         }
 
+        @Override
         public float getPreferredSpan(final int axis) {
             return axis == X_AXIS ? getWidth(id) : getHeight(id);
         }
@@ -122,35 +120,38 @@
             return id;
         }
 
-        public Shape modelToView(final int pos, final Shape shape,
-                                 final Bias bias)
+        @Override
+        public Shape modelToView(final int pos, final Shape shape, final Bias bias)
                 throws BadLocationException {
             Rectangle bounds = shape.getBounds();
             bounds.x += (pos - getStartOffset()) * POS;
             bounds.width = 1;
-            bounds.height = (int)getPreferredSpan(Y_AXIS);
+            bounds.height = (int) getPreferredSpan(Y_AXIS);
             return bounds;
         }
 
+        @Override
         public void paint(final Graphics g, final Shape shape) {
         }
 
+        @Override
         public int viewToModel(final float x, final float y, final Shape shape,
-                               final Bias[] biasReturn) {
+                final Bias[] biasReturn) {
             // We don't set biasReturn to a value
-            return (getStartOffset() + (int)(x - shape.getBounds().x) / POS);
+            return (getStartOffset() + (int) (x - shape.getBounds().x) / POS);
         }
 
+        @Override
         public float getAlignment(final int axis) {
             return getAlign(axis, id);
         }
 
+        @Override
         public void insertUpdate(final DocumentEvent event, final Shape shape,
-                                 final ViewFactory factory) {
+                final ViewFactory factory) {
             preferenceChanged(this, true, true);
             super.insertUpdate(event, shape, factory);
         }
-
     }
 
     /**
@@ -166,39 +167,40 @@
             super(element, ID);
         }
 
-        private static final float[] min = new float[] {0.25f, 1.0f, 0.5f};
-        private static final float[] max = new float[] {5.0f, 4.0f, 15.0f};
+        private static final float[] min = new float[] { 0.25f, 1.0f, 0.5f };
+
+        private static final float[] max = new float[] { 5.0f, 4.0f, 15.0f };
 
+        @Override
         public float getMaximumSpan(final int axis) {
             float result;
             if (getID() < max.length) {
-                result = max[getID()] * (axis == X_AXIS ?  WIDTH : HEIGHT);
+                result = max[getID()] * (axis == X_AXIS ? WIDTH : HEIGHT);
             } else {
-                result =  super.getMaximumSpan(axis);
+                result = super.getMaximumSpan(axis);
             }
             return result;
         }
 
+        @Override
         public float getMinimumSpan(final int axis) {
             float result;
             if (getID() < min.length) {
-                result = min[getID()] * (axis == X_AXIS ?  WIDTH : HEIGHT);
+                result = min[getID()] * (axis == X_AXIS ? WIDTH : HEIGHT);
             } else {
                 result = super.getMinimumSpan(axis);
             }
             return result;
         }
 
+        @Override
         public int getResizeWeight(final int axis) {
             int id = getID();
             if (id < min.length) {
-                int result = (int)((axis == X_AXIS ?  WIDTH : HEIGHT) *
-                        (max[id] - min[id]));
+                int result = (int) ((axis == X_AXIS ? WIDTH : HEIGHT) * (max[id] - min[id]));
                 return result;
-            } else {
-                return super.getResizeWeight(axis);
             }
-
+            return super.getResizeWeight(axis);
         }
     }
 
@@ -208,19 +210,21 @@
      */
     public static class ElementPartView extends ChildView {
         private final Position start;
+
         private final Position end;
 
-        public ElementPartView(final Element element,
-                               final int startOffset, final int endOffset) {
+        public ElementPartView(final Element element, final int startOffset, final int endOffset) {
             super(element, -1);
             start = createPosition(startOffset);
             end = createPosition(endOffset);
         }
 
+        @Override
         public int getStartOffset() {
             return start.getOffset();
         }
 
+        @Override
         public int getEndOffset() {
             return end.getOffset();
         }
@@ -245,6 +249,7 @@
          * Determins the ID of the next child created.
          */
         private int count = 0;
+
         /**
          * Determins which type of children this factory returns.
          * By default it returns ordinary children.
@@ -259,9 +264,8 @@
         public View create(final Element element) {
             if (flexibleChildren) {
                 return new FlexibleChildView(element, count++);
-            } else {
-                return new ChildView(element, count++);
             }
+            return new ChildView(element, count++);
         }
 
         /**
@@ -282,6 +286,7 @@
     }
 
     private static final String text = "javax.swing.text.";
+
     private static final String plaf = "javax.swing.plaf.basic.";
 
     public static String getViewShortClassName(final View view) {



Mime
View raw message