You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/08 01:10:24 UTC

svn commit: r454042 [5/6] - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common: java/awt/ org/apache/harmony/awt/

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPaneAdjustable.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPaneAdjustable.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPaneAdjustable.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPaneAdjustable.java Sat Oct  7 16:10:23 2006
@@ -14,50 +14,62 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Dmitry A. Durnev
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
 import java.awt.event.InvocationEvent;
 import java.io.Serializable;
-import java.util.Iterator;
-
+import java.util.Collection;
 import org.apache.harmony.awt.ScrollbarStateController;
 import org.apache.harmony.awt.state.ScrollbarState;
 import org.apache.harmony.awt.wtk.NativeWindow;
 
-
 public class ScrollPaneAdjustable implements Adjustable, Serializable {
-
     private static final long serialVersionUID = -3359745691033257079L;
 
-    private static final String errorStr = "Can be set by scrollpane only";
-    private final AWTListenerList adjustmentListeners = new AWTListenerList(null);
+    private final AWTListenerList<AdjustmentListener> adjustmentListeners = new AWTListenerList<AdjustmentListener>();
+
     private final int orientation;
+
     private final Component comp;
+
     private int value;
+
     private int visibleAmount;
+
     private int minimum;
+
     private int maximum;
+
     private int unitIncrement;
+
     private int blockIncrement;
+
     private boolean valueIsAdjusting;
-    private ScrollbarStateController stateController;
+
+    private final ScrollbarStateController stateController;
+
     private final Rectangle bounds = new Rectangle();
-    final transient State state = new State();
-    private boolean callAWTListener = false;
+
+    private final transient State state = new State();
+
+    private boolean callAWTListener;
 
     class State implements ScrollbarState {
         private final Rectangle decreaseRect = new Rectangle();
+
         private final Rectangle increaseRect = new Rectangle();
+
         private final Rectangle sliderRect = new Rectangle();
+
         private final Rectangle trackRect = new Rectangle();
+
         private final Rectangle upperTrackRect = new Rectangle();
+
         private final Rectangle lowerTrackRect = new Rectangle();
+
         private int trackSize;
 
         public Adjustable getAdjustable() {
@@ -105,7 +117,7 @@
         }
 
         public void setTrackBounds(Rectangle r) {
-           trackRect.setBounds(r);
+            trackRect.setBounds(r);
         }
 
         public Rectangle getUpperTrackBounds() {
@@ -133,11 +145,11 @@
         }
 
         public void setIncreaseRect(Rectangle r) {
-           increaseRect.setRect(r);
+            increaseRect.setRect(r);
         }
 
         public void setTrackSize(int size) {
-          trackSize = size;
+            trackSize = size;
         }
 
         public int getTrackSize() {
@@ -153,7 +165,7 @@
         public Rectangle getIncreaseRect() {
             return increaseRect;
         }
- 
+
         public Rectangle getDecreaseRect() {
             return decreaseRect;
         }
@@ -226,13 +238,11 @@
 
         public void setValue(int type, int value) {
             ScrollPaneAdjustable.this.setValue(type, value);
-
         }
 
         public boolean isTextColorSet() {
             return false;
         }
-
     }
 
     ScrollPaneAdjustable(Component comp, int orientation) {
@@ -241,7 +251,6 @@
         unitIncrement = 1;
         blockIncrement = 1;
         stateController = new ScrollbarStateController(state) {
-
             @Override
             protected void fireEvent() {
                 generateEvent();
@@ -254,7 +263,7 @@
 
             @Override
             protected void repaint() {
-               doRepaint();
+                doRepaint();
             }
 
             @Override
@@ -315,23 +324,21 @@
          * System.out.println(new ScrollPane().getVAdjustable());
          * System.out.println(new ScrollPane().getHAdjustable());
          */
-
         String orientStr = "";
         switch (orientation) {
-        case Adjustable.HORIZONTAL:
-            orientStr = "horizontal";
-            break;
-        case Adjustable.VERTICAL:
-            orientStr = "vertical";
-            break;
-        case Adjustable.NO_ORIENTATION:
-            orientStr = "no orientation";
-            break;
-        }
-        return (orientStr + ",val=" + value + ",vis=" + visibleAmount +
-                ",[" + minimum + ".." + maximum + "]" +
-                ",unit=" + unitIncrement + ",block=" + blockIncrement +
-                ",isAdjusting=" + valueIsAdjusting);
+            case Adjustable.HORIZONTAL:
+                orientStr = "horizontal";
+                break;
+            case Adjustable.VERTICAL:
+                orientStr = "vertical";
+                break;
+            case Adjustable.NO_ORIENTATION:
+                orientStr = "no orientation";
+                break;
+        }
+        return (orientStr + ",val=" + value + ",vis=" + visibleAmount + ",[" + minimum + ".."
+                + maximum + "]" + ",unit=" + unitIncrement + ",block=" + blockIncrement
+                + ",isAdjusting=" + valueIsAdjusting);
     }
 
     public void setBlockIncrement(int b) {
@@ -339,11 +346,11 @@
     }
 
     public void setMaximum(int max) {
-        throw new AWTError(errorStr);
+        throw new AWTError("Can be set by scrollpane only");
     }
 
     public void setMinimum(int min) {
-        throw new AWTError(errorStr);
+        throw new AWTError("Can be set by scrollpane only");
     }
 
     public void setUnitIncrement(int u) {
@@ -355,7 +362,7 @@
     }
 
     public void setVisibleAmount(int vis) {
-        throw new AWTError(errorStr);
+        throw new AWTError("Can be set by scrollpane only");
     }
 
     public void addAdjustmentListener(AdjustmentListener l) {
@@ -367,8 +374,7 @@
     }
 
     public AdjustmentListener[] getAdjustmentListeners() {
-        return (AdjustmentListener[]) adjustmentListeners.
-        getUserListeners(new AdjustmentListener[0]);
+        return adjustmentListeners.getUserListeners(new AdjustmentListener[0]);
     }
 
     final Rectangle getBounds() {
@@ -418,25 +424,20 @@
 
     private void postAdjustmentEvent(final int type) {
         // create and post invocation event here:
-        comp.postEvent(new InvocationEvent(ScrollPaneAdjustable.this,
-                                                 new Runnable() {
+        comp.postEvent(new InvocationEvent(ScrollPaneAdjustable.this, new Runnable() {
             public void run() {
-                AdjustmentEvent event = new AdjustmentEvent(
-                                ScrollPaneAdjustable.this,
-                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type,
-                                value, getValueIsAdjusting());
+                AdjustmentEvent event = new AdjustmentEvent(ScrollPaneAdjustable.this,
+                        AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type, value,
+                        getValueIsAdjusting());
                 if (callAWTListener) {
                     comp.toolkit.lockAWT();
                     try {
-                        processAdjustmentEvent(event,
-                                               adjustmentListeners.getSystemIterator());
+                        processAdjustmentEvent(event, adjustmentListeners.getSystemListeners());
                     } finally {
                         comp.toolkit.unlockAWT();
                     }
                 }
-                processAdjustmentEvent(event,
-                                       adjustmentListeners.getUserIterator());
-
+                processAdjustmentEvent(event, adjustmentListeners.getUserListeners());
             }
         }));
     }
@@ -463,18 +464,14 @@
         }
     }
 
-    void processAdjustmentEvent(AdjustmentEvent e, Iterator i) {
-
-        while (i.hasNext()) {
-            AdjustmentListener listener = (AdjustmentListener) i.next();
-
+    void processAdjustmentEvent(AdjustmentEvent e, Collection<AdjustmentListener> c) {
+        for (AdjustmentListener listener : c) {
             switch (e.getID()) {
-            case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
-                listener.adjustmentValueChanged(e);
-                break;
+                case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
+                    listener.adjustmentValueChanged(e);
+                    break;
             }
         }
-
     }
 
     void setValue(int type, int val) {
@@ -483,7 +480,6 @@
         if (oldVal != value) {
             Rectangle oldRect = new Rectangle(state.getSliderRect());
             comp.toolkit.theme.layoutScrollbar(state); //TODO: FIXME
-
             Rectangle paintRect = oldRect.union(state.getSliderRect());
             paintRect.grow(0, 1);
             postAdjustmentEvent(type);
@@ -499,6 +495,4 @@
     ScrollbarStateController getStateController() {
         return stateController;
     }
-
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Scrollbar.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Scrollbar.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Scrollbar.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Scrollbar.java Sat Oct  7 16:10:23 2006
@@ -14,36 +14,26 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Dmitry A. Durnev
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
 import java.util.EventListener;
-import java.util.Iterator;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
 import javax.accessibility.AccessibleValue;
-
 import org.apache.harmony.awt.ScrollbarStateController;
 import org.apache.harmony.awt.state.ScrollbarState;
 
-
 public class Scrollbar extends Component implements Adjustable, Accessible {
-
     private static final long serialVersionUID = 8451667562882310543L;
 
-    protected class AccessibleAWTScrollBar
-    extends Component.AccessibleAWTComponent
-    implements AccessibleValue {
-
+    protected class AccessibleAWTScrollBar extends Component.AccessibleAWTComponent implements
+            AccessibleValue {
         private static final long serialVersionUID = -344337268523697807L;
 
         @Override
@@ -58,12 +48,12 @@
                 AccessibleStateSet aStateSet = super.getAccessibleStateSet();
                 AccessibleState aState = null;
                 switch (getOrientation()) {
-                case VERTICAL:
-                    aState = AccessibleState.VERTICAL;
-                    break;
-                case HORIZONTAL:
-                    aState = AccessibleState.HORIZONTAL;
-                    break;
+                    case VERTICAL:
+                        aState = AccessibleState.VERTICAL;
+                        break;
+                    case HORIZONTAL:
+                        aState = AccessibleState.HORIZONTAL;
+                        break;
                 }
                 if (aState != null) {
                     aStateSet.add(aState);
@@ -95,7 +85,6 @@
             setValue(n.intValue());
             return true;
         }
-
     }
 
     public static final int HORIZONTAL = 0;
@@ -103,16 +92,28 @@
     public static final int VERTICAL = 1;
 
     final static int MAX = Integer.MAX_VALUE;
-    private final AWTListenerList adjustmentListeners = new AWTListenerList(this);
+
+    private final AWTListenerList<AdjustmentListener> adjustmentListeners = new AWTListenerList<AdjustmentListener>(
+            this);
+
     private int blockIncrement;
+
     private int unitIncrement;
+
     private int maximum;
+
     private int minimum;
+
     private int orientation;
+
     private int value;
+
     private transient boolean valueIsAdjusting;
+
     private int visibleAmount;
+
     final transient State state = new State();
+
     private final transient ScrollbarStateController stateController;
 
     public Scrollbar() throws HeadlessException {
@@ -133,8 +134,8 @@
         }
     }
 
-    public Scrollbar(int orientation, int value,
-                     int visible, int min, int max) throws HeadlessException {
+    public Scrollbar(int orientation, int value, int visible, int min, int max)
+            throws HeadlessException {
         toolkit.lockAWT();
         try {
             setOrientation(orientation);
@@ -142,7 +143,6 @@
             setUnitIncrement(1);
             setBlockIncrement(10);
             stateController = new ScrollbarStateController(state) {
-
                 @Override
                 protected void fireEvent() {
                     generateEvent();
@@ -155,7 +155,7 @@
 
                 @Override
                 protected void repaint() {
-                   doRepaint();
+                    doRepaint();
                 }
 
                 @Override
@@ -176,13 +176,18 @@
     }
 
     class State extends Component.ComponentState implements ScrollbarState {
-
         private final Rectangle decreaseRect = new Rectangle();
+
         private final Rectangle increaseRect = new Rectangle();
+
         private final Rectangle sliderRect = new Rectangle();
+
         private final Rectangle trackRect = new Rectangle();
+
         private final Rectangle upperTrackRect = new Rectangle();
+
         private final Rectangle lowerTrackRect = new Rectangle();
+
         private int trackSize;
 
         public boolean isDecreasePressed() {
@@ -232,7 +237,7 @@
         }
 
         public void setIncreaseRect(Rectangle r) {
-           increaseRect.setRect(r);
+            increaseRect.setRect(r);
         }
 
         public void setDecreaseRect(Rectangle r) {
@@ -244,7 +249,7 @@
         }
 
         public void setTrackSize(int size) {
-          trackSize = size;
+            trackSize = size;
         }
 
         public Adjustable getAdjustable() {
@@ -260,7 +265,7 @@
         }
 
         public void setTrackBounds(Rectangle r) {
-           trackRect.setBounds(r);
+            trackRect.setBounds(r);
         }
 
         public ComponentOrientation getComponentOrientation() {
@@ -304,7 +309,6 @@
         }
     }
 
-
     public int getValue() {
         toolkit.lockAWT();
         try {
@@ -452,16 +456,11 @@
          * System.out.println(new Scrollbar());
          * System.out.println(new Scrollbar(Scrollbar.HORIZONTAL));
          */
-
         toolkit.lockAWT();
         try {
-            return (super.paramString() +
-                    ",val=" + getValue() +
-                    ",vis=" + getVisibleAmount() +
-                    ",min=" + getMinimum() +
-                    ",max=" + getMaximum() +
-                    (getOrientation() == HORIZONTAL ? ",horz" : ",vert") +
-                    ",isAdjusting=" + getValueIsAdjusting());
+            return (super.paramString() + ",val=" + getValue() + ",vis=" + getVisibleAmount()
+                    + ",min=" + getMinimum() + ",max=" + getMaximum()
+                    + (getOrientation() == HORIZONTAL ? ",horz" : ",vert") + ",isAdjusting=" + getValueIsAdjusting());
         } finally {
             toolkit.unlockAWT();
         }
@@ -517,8 +516,7 @@
     public void setOrientation(int orientation) {
         toolkit.lockAWT();
         try {
-            if ((orientation != HORIZONTAL) &&
-                (orientation != VERTICAL)) {
+            if ((orientation != HORIZONTAL) && (orientation != VERTICAL)) {
                 throw new IllegalArgumentException("illegal scrollbar orientation");
             }
             this.orientation = orientation;
@@ -571,12 +569,13 @@
     public void setVisibleAmount(int newAmount) {
         toolkit.lockAWT();
         try {
-           setValues(value, newAmount, minimum, maximum);
+            setValues(value, newAmount, minimum, maximum);
         } finally {
             toolkit.unlockAWT();
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         if (AdjustmentListener.class.isAssignableFrom(listenerType)) {
@@ -594,15 +593,12 @@
     }
 
     public AdjustmentListener[] getAdjustmentListeners() {
-        return (AdjustmentListener[]) adjustmentListeners.
-        getUserListeners(new AdjustmentListener[0]);
+        return adjustmentListeners.getUserListeners(new AdjustmentListener[0]);
     }
 
     @Override
     protected void processEvent(AWTEvent e) {
-        if (toolkit.eventTypeLookup.getEventMask(e) ==
-            AWTEvent.ADJUSTMENT_EVENT_MASK) {
-
+        if (toolkit.eventTypeLookup.getEventMask(e) == AWTEvent.ADJUSTMENT_EVENT_MASK) {
             processAdjustmentEvent((AdjustmentEvent) e);
         } else {
             super.processEvent(e);
@@ -610,13 +606,11 @@
     }
 
     protected void processAdjustmentEvent(AdjustmentEvent e) {
-        for (Iterator i = adjustmentListeners.getUserIterator(); i.hasNext();) {
-            AdjustmentListener listener = (AdjustmentListener) i.next();
-
+        for (AdjustmentListener listener : adjustmentListeners.getUserListeners()) {
             switch (e.getID()) {
-            case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
-                listener.adjustmentValueChanged(e);
-                break;
+                case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
+                    listener.adjustmentValueChanged(e);
+                    break;
             }
         }
     }
@@ -673,10 +667,8 @@
             return;
         }
         setValueIsAdjusting(stateController.isSliderDragged());
-
-        postEvent(new AdjustmentEvent(this,
-                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type, value,
-                getValueIsAdjusting()));
+        postEvent(new AdjustmentEvent(this, AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type,
+                value, getValueIsAdjusting()));
     }
 
     @Override
@@ -689,24 +681,18 @@
         state.reset();
     }
 
-    void setValuesImpl(int value, int visible, int min, int max,
-                       boolean repaint) {
+    void setValuesImpl(int value, int visible, int min, int max, boolean repaint) {
         int oldValue = this.value;
         int oldMin = minimum;
-
         minimum = Math.min(min, MAX - 1);
         maximum = Math.max(minimum + 1, max);
         if (maximum - minimum < 0) {
             maximum = minimum + MAX;
         }
-
         visibleAmount = Math.max(1, visible);
         visibleAmount = Math.min(maximum - minimum, visibleAmount);
-
-
         this.value = Math.max(minimum, value);
         this.value = Math.min(this.value, maximum - visibleAmount);
-
         repaint &= (oldValue != this.value) || (oldMin != minimum);
         if (repaint) {
             doRepaint();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextArea.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextArea.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextArea.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextArea.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.InputEvent;
@@ -27,23 +24,18 @@
 import java.awt.event.MouseMotionListener;
 import java.util.HashSet;
 import java.util.Set;
-
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.View;
-
 import org.apache.harmony.awt.ScrollStateController;
 import org.apache.harmony.awt.Scrollable;
 import org.apache.harmony.awt.text.TextFactory;
 import org.apache.harmony.awt.wtk.NativeWindow;
 
-
 public class TextArea extends TextComponent {
-
     protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent {
-
         private static final long serialVersionUID = 3472827823632144419L;
 
         @Override
@@ -52,15 +44,12 @@
             set.add(AccessibleState.MULTI_LINE);
             return set;
         }
-
-
     }
 
     /**
      * Scrolling behavior implementation
      */
     class TextScrollable implements Scrollable {
-
         public Adjustable getVAdjustable() {
             return vAdjustable;
         }
@@ -94,7 +83,6 @@
 
         public void doRepaint() {
             TextArea.this.doRepaint();
-
         }
 
         public int getAdjustableWidth() {
@@ -111,22 +99,21 @@
 
         public int getAdjustableMode(Adjustable adj) {
             switch (getScrollbarVisibility()) {
-            case SCROLLBARS_BOTH:
-                return Scrollable.ALWAYS;
-            case SCROLLBARS_HORIZONTAL_ONLY:
-                return Scrollable.HORIZONTAL_ONLY;
-            case SCROLLBARS_NONE:
-                return Scrollable.NEVER;
-            case SCROLLBARS_VERTICAL_ONLY:
-                return Scrollable.VERTICAL_ONLY;
-            default:
-                return Scrollable.NEVER;
+                case SCROLLBARS_BOTH:
+                    return Scrollable.ALWAYS;
+                case SCROLLBARS_HORIZONTAL_ONLY:
+                    return Scrollable.HORIZONTAL_ONLY;
+                case SCROLLBARS_NONE:
+                    return Scrollable.NEVER;
+                case SCROLLBARS_VERTICAL_ONLY:
+                    return Scrollable.VERTICAL_ONLY;
+                default:
+                    return Scrollable.NEVER;
             }
         }
 
         public void setAdjustableBounds(Adjustable adj, Rectangle r) {
-            ((ScrollPaneAdjustable)adj).setBounds(r);
-
+            ((ScrollPaneAdjustable) adj).setBounds(r);
         }
 
         public int getWidth() {
@@ -140,7 +127,6 @@
         public void doRepaint(Rectangle r) {
             TextArea.this.doRepaint(r);
         }
-
     }
 
     /**
@@ -150,9 +136,13 @@
      */
     class MouseEventFilter implements MouseListener, MouseMotionListener {
         private final MouseListener mListener;
+
         private final MouseMotionListener mmListener;
+
         private boolean inside = true;
+
         boolean clientDrag;
+
         boolean scrollDrag;
 
         public MouseEventFilter(MouseListener ml, MouseMotionListener mml) {
@@ -170,7 +160,6 @@
             } else {
                 setDefaultCursor();
             }
-
         }
 
         public void mouseEntered(MouseEvent e) {
@@ -222,7 +211,6 @@
                 setDefaultCursor();
                 inside = false;
             }
-
         }
 
         private void setDefaultCursor() {
@@ -236,7 +224,6 @@
             }
             Cursor.getDefaultCursor().getNativeCursor().setCursor(wnd.getId());
         }
-
     }
 
     private static final long serialVersionUID = 3692302836626095722L;
@@ -256,11 +243,14 @@
     private int scrollbarVisibility = SCROLLBARS_BOTH;
 
     private ScrollPaneAdjustable hAdjustable;
+
     private ScrollPaneAdjustable vAdjustable;
+
     private final ScrollStateController stateController;
+
     private final Scrollable scrollable;
-    private MouseEventFilter filter;
 
+    private MouseEventFilter filter;
 
     public TextArea() throws HeadlessException {
         this(new String(), 0, 0, SCROLLBARS_BOTH);
@@ -272,18 +262,16 @@
     }
 
     public TextArea(String text, int rows, int columns, int scrollbars)
-    throws HeadlessException {
+            throws HeadlessException {
         super();
         toolkit.lockAWT();
         try {
             Toolkit.checkHeadless();
-
             setFont(new Font("Dialog", Font.PLAIN, 12)); // QUICK FIX
             setText(text);
             this.rows = Math.max(0, rows);
             this.columns = Math.max(0, columns);
-            if ((scrollbars < SCROLLBARS_BOTH) ||
-                (scrollbars > SCROLLBARS_NONE)) {
+            if ((scrollbars < SCROLLBARS_BOTH) || (scrollbars > SCROLLBARS_NONE)) {
                 scrollbars = SCROLLBARS_BOTH;
             }
             scrollbarVisibility = scrollbars;
@@ -297,7 +285,6 @@
             scrollable = new TextScrollable();
             stateController = new ScrollStateController(scrollable);
             addScrolling();
-
         } finally {
             toolkit.unlockAWT();
         }
@@ -308,17 +295,16 @@
      */
     private void setFocusTraversalKeys() {
         int id = KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS;
-        Set set = new HashSet(getFocusTraversalKeys(id));
+        Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(getFocusTraversalKeys(id));
         AWTKeyStroke tab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0);
         AWTKeyStroke shiftTab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,
-                                                             InputEvent.SHIFT_DOWN_MASK);
+                InputEvent.SHIFT_DOWN_MASK);
         set.remove(tab);
         setFocusTraversalKeys(id, set);
         id = KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS;
-        set = new HashSet(getFocusTraversalKeys(id));
+        set = new HashSet<AWTKeyStroke>(getFocusTraversalKeys(id));
         set.remove(shiftTab);
         setFocusTraversalKeys(id, set);
-
     }
 
     /**
@@ -333,8 +319,7 @@
     }
 
     private boolean noHorizontalScroll() {
-        return ((scrollbarVisibility == SCROLLBARS_NONE) ||
-                (scrollbarVisibility == SCROLLBARS_VERTICAL_ONLY));
+        return ((scrollbarVisibility == SCROLLBARS_NONE) || (scrollbarVisibility == SCROLLBARS_VERTICAL_ONLY));
     }
 
     public TextArea(String text, int rows, int columns) throws HeadlessException {
@@ -370,18 +355,18 @@
         } catch (BadLocationException e) {
             throw new RuntimeException(e);
         }
-//        toolkit.lockAWT();
-//        try {
-            if (isDisplayable()) {
-                // update caret position on text append
-                int newCaretPos = document.getLength();
-                if (caret.getDot() != newCaretPos) {
-                    caret.setDot(newCaretPos, caret.getDotBias());
-                }
+        //        toolkit.lockAWT();
+        //        try {
+        if (isDisplayable()) {
+            // update caret position on text append
+            int newCaretPos = document.getLength();
+            if (caret.getDot() != newCaretPos) {
+                caret.setDot(newCaretPos, caret.getDotBias());
             }
-//        } finally {
-//            toolkit.unlockAWT();
-//        }
+        }
+        //        } finally {
+        //            toolkit.unlockAWT();
+        //        }
     }
 
     public void insert(String str, int pos) {
@@ -391,21 +376,21 @@
         } catch (BadLocationException e) {
             throw new IndexOutOfBoundsException();
         }
-//        toolkit.lockAWT();
-//        try {
-            if (isDisplayable()) {
-                // update caret position on text insertion
-                int newCaretPos = pos + str.length();
-                if (caret.getDot() != newCaretPos) {
-                    caret.setDot(newCaretPos, caret.getDotBias());
-                }
-            } else if (caret.getDot() != oldPos) {
-                // move caret back:
-                caret.setDot(oldPos, caret.getDotBias());
-            }
-//        } finally {
-//            toolkit.unlockAWT();
-//        }
+        //        toolkit.lockAWT();
+        //        try {
+        if (isDisplayable()) {
+            // update caret position on text insertion
+            int newCaretPos = pos + str.length();
+            if (caret.getDot() != newCaretPos) {
+                caret.setDot(newCaretPos, caret.getDotBias());
+            }
+        } else if (caret.getDot() != oldPos) {
+            // move caret back:
+            caret.setDot(oldPos, caret.getDotBias());
+        }
+        //        } finally {
+        //            toolkit.unlockAWT();
+        //        }
     }
 
     @Override
@@ -418,9 +403,6 @@
         }
     }
 
-    /**
-     * @deprecated
-     */
     @Deprecated
     public void appendText(String str) {
         append(str);
@@ -521,7 +503,6 @@
             if ((rows > 0) && (columns > 0)) {
                 return minimumSize(rows, columns);
             }
-
             return super.minimumSize();
         } finally {
             toolkit.unlockAWT();
@@ -552,27 +533,25 @@
          * which can be revealed by the following code:
          * System.out.println(new TextArea());
          */
-
         toolkit.lockAWT();
         try {
             String strScrollbarVis = null;
             switch (getScrollbarVisibility()) {
-            case SCROLLBARS_BOTH:
-                strScrollbarVis = "both";
-                break;
-            case SCROLLBARS_HORIZONTAL_ONLY:
-                strScrollbarVis = "horizontal only";
-                break;
-            case SCROLLBARS_NONE:
-                strScrollbarVis = "none";
-                break;
-            case SCROLLBARS_VERTICAL_ONLY:
-                strScrollbarVis = "vertical only";
-                break;
-            }
-            return (super.paramString() + ",rows=" + getRows() +
-                    ",columns=" + getColumns() +
-                    ",scrollbarVisibility=" + strScrollbarVis);
+                case SCROLLBARS_BOTH:
+                    strScrollbarVis = "both";
+                    break;
+                case SCROLLBARS_HORIZONTAL_ONLY:
+                    strScrollbarVis = "horizontal only";
+                    break;
+                case SCROLLBARS_NONE:
+                    strScrollbarVis = "none";
+                    break;
+                case SCROLLBARS_VERTICAL_ONLY:
+                    strScrollbarVis = "vertical only";
+                    break;
+            }
+            return (super.paramString() + ",rows=" + getRows() + ",columns=" + getColumns()
+                    + ",scrollbarVisibility=" + strScrollbarVis);
         } finally {
             toolkit.unlockAWT();
         }
@@ -590,9 +569,7 @@
             if ((rows > 0) && (columns > 0)) {
                 return preferredSize(rows, columns);
             }
-
             return super.preferredSize();
-
         } finally {
             toolkit.unlockAWT();
         }
@@ -636,7 +613,6 @@
                 // move caret back:
                 caret.setDot(oldPos, caret.getDotBias());
             }
-
         } finally {
             toolkit.unlockAWT();
         }
@@ -690,7 +666,6 @@
             return null;
         }
         return getDefaultMinimumSize();
-
     }
 
     /**
@@ -702,11 +677,8 @@
         if ((fm == null) || !isDisplayable()) {
             return null;
         }
-
         int avWidth = fm.charWidth('_'); // take width of an 'average' character
-
-        return new Dimension( avWidth * columns + 4,
-                             (fm.getHeight() + 1) * rows + 4);
+        return new Dimension(avWidth * columns + 4, (fm.getHeight() + 1) * rows + 4);
     }
 
     /**
@@ -838,8 +810,7 @@
      * @return mouse event filter for caret
      */
     MouseEventFilter createFilter() {
-        filter = new MouseEventFilter((MouseListener)caret,
-                                      (MouseMotionListener)caret);
+        filter = new MouseEventFilter((MouseListener) caret, (MouseMotionListener) caret);
         return filter;
     }
 
@@ -858,11 +829,9 @@
         }
         return filter;
     }
-    
+
     @Override
-    String autoName() {        
+    String autoName() {
         return ("text" + toolkit.autoNumber.nextTextArea++);
     }
-    
 }
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextComponent.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextComponent.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextComponent.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextComponent.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.FocusEvent;
@@ -33,8 +30,6 @@
 import java.text.BreakIterator;
 import java.util.EventListener;
 import java.util.HashMap;
-import java.util.Iterator;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
@@ -52,7 +47,6 @@
 import javax.swing.text.View;
 import javax.swing.text.ViewFactory;
 import javax.swing.text.Position.Bias;
-
 import org.apache.harmony.awt.state.TextComponentState;
 import org.apache.harmony.awt.text.AWTTextAction;
 import org.apache.harmony.awt.text.ActionNames;
@@ -63,65 +57,55 @@
 import org.apache.harmony.awt.text.TextKit;
 
 public class TextComponent extends Component implements Accessible {
-
     private static final long serialVersionUID = -2214773872412987419L;
 
     /**
      * Maps KeyEvents to keyboard actions
      */
     static class KeyMap {
-
         private static final HashMap<AWTKeyStroke, Object> actions = new HashMap<AWTKeyStroke, Object>();
-
         static {
             add(KeyEvent.VK_ENTER, 0, ActionNames.insertBreakAction);
             add(KeyEvent.VK_TAB, 0, ActionNames.insertTabAction);
             add(KeyEvent.VK_DELETE, 0, ActionNames.deleteNextCharAction);
             add(KeyEvent.VK_BACK_SPACE, 0, ActionNames.deletePrevCharAction);
-
             add(KeyEvent.VK_LEFT, 0, ActionNames.backwardAction);
             add(KeyEvent.VK_RIGHT, 0, ActionNames.forwardAction);
             add(KeyEvent.VK_UP, 0, ActionNames.upAction);
             add(KeyEvent.VK_DOWN, 0, ActionNames.downAction);
-
             add(KeyEvent.VK_HOME, 0, ActionNames.beginLineAction);
             add(KeyEvent.VK_END, 0, ActionNames.endLineAction);
             add(KeyEvent.VK_PAGE_UP, 0, ActionNames.pageUpAction);
             add(KeyEvent.VK_PAGE_DOWN, 0, ActionNames.pageDownAction);
-
             add(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK, ActionNames.nextWordAction);
             add(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK, ActionNames.previousWordAction);
             add(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK, ActionNames.beginAction);
             add(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_MASK, ActionNames.endAction);
             add(KeyEvent.VK_HOME, InputEvent.CTRL_MASK, ActionNames.beginAction);
             add(KeyEvent.VK_END, InputEvent.CTRL_MASK, ActionNames.endAction);
-
             add(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK, ActionNames.selectionBackwardAction);
             add(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK, ActionNames.selectionForwardAction);
             add(KeyEvent.VK_UP, InputEvent.SHIFT_MASK, ActionNames.selectionUpAction);
             add(KeyEvent.VK_DOWN, InputEvent.SHIFT_MASK, ActionNames.selectionDownAction);
-
             add(KeyEvent.VK_HOME, InputEvent.SHIFT_MASK, ActionNames.selectionBeginLineAction);
             add(KeyEvent.VK_END, InputEvent.SHIFT_MASK, ActionNames.selectionEndLineAction);
             add(KeyEvent.VK_PAGE_UP, InputEvent.SHIFT_MASK, ActionNames.selectionPageUpAction);
-            add(KeyEvent.VK_PAGE_DOWN, InputEvent.SHIFT_MASK, ActionNames.selectionPageDownAction);
-
-            add(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK,
+            add(KeyEvent.VK_PAGE_DOWN, InputEvent.SHIFT_MASK,
+                    ActionNames.selectionPageDownAction);
+            add(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK,
                     ActionNames.selectionPreviousWordAction);
-            add(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK,
+            add(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK,
                     ActionNames.selectionNextWordAction);
-            add(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK,
+            add(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK,
                     ActionNames.selectionBeginAction);
-            add(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK,
+            add(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK,
                     ActionNames.selectionEndAction);
             add(KeyEvent.VK_A, InputEvent.CTRL_MASK, ActionNames.selectAllAction);
-
             add(KeyEvent.VK_INSERT, InputEvent.SHIFT_MASK, ActionNames.pasteAction);
             add(KeyEvent.VK_V, InputEvent.CTRL_MASK, ActionNames.pasteAction);
             add(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK, ActionNames.copyAction);
             add(KeyEvent.VK_C, InputEvent.CTRL_MASK, ActionNames.copyAction);
             add(KeyEvent.VK_X, InputEvent.CTRL_MASK, ActionNames.cutAction);
-
         }
 
         private static void add(int vk, int mask, String actionName) {
@@ -130,13 +114,12 @@
         }
 
         static AWTTextAction getAction(KeyEvent e) {
-            return (AWTTextAction)actions.get(AWTKeyStroke.getAWTKeyStrokeForEvent(e));
+            return (AWTTextAction) actions.get(AWTKeyStroke.getAWTKeyStrokeForEvent(e));
         }
     }
 
-    protected class AccessibleAWTTextComponent extends AccessibleAWTComponent
-    implements AccessibleText, TextListener {
-
+    protected class AccessibleAWTTextComponent extends AccessibleAWTComponent implements
+            AccessibleText, TextListener {
         private static final long serialVersionUID = 3631432373506317811L;
 
         public AccessibleAWTTextComponent() {
@@ -196,22 +179,20 @@
         public String getAfterIndex(int part, int index) {
             int offset = 0;
             switch (part) {
-            case AccessibleText.CHARACTER:
-                return (index == document.getLength()) ? null
-                        : getCharacter(index + 1);
-            case AccessibleText.WORD:
-                try {
-                    offset = getWordEnd(index) + 1;
-                    offset = getWordEnd(offset + 1);
-                } catch (final BadLocationException e) {
+                case AccessibleText.CHARACTER:
+                    return (index == document.getLength()) ? null : getCharacter(index + 1);
+                case AccessibleText.WORD:
+                    try {
+                        offset = getWordEnd(index) + 1;
+                        offset = getWordEnd(offset + 1);
+                    } catch (final BadLocationException e) {
+                        return null;
+                    }
+                    return getWord(offset);
+                case AccessibleText.SENTENCE:
+                    // not implemented yet
+                default:
                     return null;
-                }
-                return getWord(offset);
-            case AccessibleText.SENTENCE:
-                // not implemented yet
-
-            default:
-                return null;
             }
         }
 
@@ -220,38 +201,38 @@
                 return null; // compatibility
             }
             switch (part) {
-            case AccessibleText.CHARACTER:
-                return getCharacter(index);
-            case AccessibleText.WORD:
-                return getWord(index);
-            case AccessibleText.SENTENCE:
-                return getLine(index);
-            default:
-                return null;
+                case AccessibleText.CHARACTER:
+                    return getCharacter(index);
+                case AccessibleText.WORD:
+                    return getWord(index);
+                case AccessibleText.SENTENCE:
+                    return getLine(index);
+                default:
+                    return null;
             }
         }
 
         public String getBeforeIndex(int part, int index) {
             int offset = 0;
             switch (part) {
-            case AccessibleText.CHARACTER:
-                return (index == 0) ? null : getCharacter(index - 1);
-            case AccessibleText.WORD:
-                try {
-                    offset = getWordStart(index) - 1;
-                    offset = getWordStart(offset - 1);
-                } catch (final BadLocationException e) {
+                case AccessibleText.CHARACTER:
+                    return (index == 0) ? null : getCharacter(index - 1);
+                case AccessibleText.WORD:
+                    try {
+                        offset = getWordStart(index) - 1;
+                        offset = getWordStart(offset - 1);
+                    } catch (final BadLocationException e) {
+                        return null;
+                    }
+                    return (offset < 0) ? null : getWord(offset);
+                case AccessibleText.SENTENCE:
+                    BreakIterator bi = BreakIterator.getSentenceInstance();
+                    bi.setText(getText());
+                    offset = bi.preceding(index);
+                    offset = bi.previous() + 1;
+                    return (offset < 0) ? null : getLine(offset);
+                default:
                     return null;
-                }
-                return (offset < 0) ? null : getWord(offset);
-            case AccessibleText.SENTENCE:
-                BreakIterator bi = BreakIterator.getSentenceInstance();
-                bi.setText(getText());
-                offset = bi.preceding(index);
-                offset = bi.previous() + 1;
-                return (offset < 0) ? null : getLine(offset);
-            default:
-                return null;
             }
         }
 
@@ -262,9 +243,7 @@
 
         public void textValueChanged(TextEvent e) {
             // TODO: implement
-
         }
-
     }
 
     /**
@@ -272,7 +251,6 @@
      * key typed events
      */
     final class KeyHandler implements KeyListener {
-
         public void keyPressed(KeyEvent e) {
             performAction(e);
         }
@@ -282,7 +260,7 @@
 
         public void keyTyped(KeyEvent e) {
             if (insertCharacter(e)) {
-//                repaint();
+                //                repaint();
             } else {
                 performAction(e);
             }
@@ -302,7 +280,7 @@
         }
 
         void performAction(KeyEvent e) {
-            AWTTextAction action = KeyMap.getAction(e);            
+            AWTTextAction action = KeyMap.getAction(e);
             if (action != null) {
                 performTextAction(action);
                 e.consume();
@@ -314,7 +292,6 @@
      * Handles Document changes, updates view
      */
     final class DocumentHandler implements DocumentListener {
-
         private Rectangle getScrollPosition() {
             Rectangle pos = getClient();
             pos.translate(scrollPosition.x, scrollPosition.y);
@@ -326,17 +303,13 @@
                 // update view only when component is "viewable"
                 return;
             }
-
-            getRootView().insertUpdate(e, getScrollPosition(),
-                    getRootView().getViewFactory());
-
+            getRootView().insertUpdate(e, getScrollPosition(), getRootView().getViewFactory());
             updateBidiInfo();
             generateEvent();
         }
 
         private void updateBidiInfo() {
             // TODO catch BIDI chars here
-
         }
 
         public void removeUpdate(DocumentEvent e) {
@@ -344,8 +317,7 @@
                 // update view only when component is "viewable"
                 return;
             }
-            getRootView().removeUpdate(e, getScrollPosition(), getRootView()
-                    .getViewFactory());
+            getRootView().removeUpdate(e, getScrollPosition(), getRootView().getViewFactory());
             generateEvent();
         }
 
@@ -354,8 +326,7 @@
                 // update view only when component is "viewable"
                 return;
             }
-            getRootView().changedUpdate(e, getScrollPosition(),
-                    getRootView().getViewFactory());
+            getRootView().changedUpdate(e, getScrollPosition(), getRootView().getViewFactory());
             generateEvent();
         }
 
@@ -367,130 +338,123 @@
     /**
      * Implements all necessary document/view/caret operations for text handling
      */
-    class TextKitImpl implements TextKit, ViewFactory,
-                RootViewContext.ViewFactoryGetter {
+    class TextKitImpl implements TextKit, ViewFactory, RootViewContext.ViewFactoryGetter {
+        public boolean isEditable() {
+            return TextComponent.this.isEditable();
+        }
 
-            public boolean isEditable() {
-                return TextComponent.this.isEditable();
+        public void replaceSelectedText(String text) {
+            int dot = caret.getDot();
+            int mark = caret.getMark();
+            try {
+                int start = Math.min(dot, mark);
+                int length = Math.abs(dot - mark);
+                document.replace(start, length, text, null);
+            } catch (final BadLocationException e) {
             }
+        }
 
-            public void replaceSelectedText(String text) {
-                int dot = caret.getDot();
-                int mark = caret.getMark();
-                try {
-                    int start = Math.min(dot, mark);
-                    int length = Math.abs(dot - mark);
-                    document.replace(start, length, text, null);
-                } catch (final BadLocationException e) { }
-            }
+        public TextCaret getCaret() {
+            return caret;
+        }
 
-            public TextCaret getCaret() {
-                return caret;
-            }
+        public Document getDocument() {
+            return document;
+        }
 
-            public Document getDocument() {
-                return document;
+        public String getSelectedText() {
+            String s = null;
+            int dot = caret.getDot();
+            int mark = caret.getMark();
+            if (dot == mark) {
+                return null;
             }
-
-            public String getSelectedText() {
-                String s = null;
-                int dot = caret.getDot();
-                int mark = caret.getMark();
-                if (dot == mark) {
-                    return null;
-                }
-                try {
-                    s = document.getText(Math.min(dot, mark), Math.abs(dot - mark));
-                } catch (final BadLocationException e) { }
-                return s;
+            try {
+                s = document.getText(Math.min(dot, mark), Math.abs(dot - mark));
+            } catch (final BadLocationException e) {
             }
+            return s;
+        }
 
-            public int getSelectionStart() {
-                return Math.min(caret.getDot(), caret.getMark());
-            }
+        public int getSelectionStart() {
+            return Math.min(caret.getDot(), caret.getMark());
+        }
 
-            public int getSelectionEnd() {
-                return Math.max(caret.getDot(), caret.getMark());
-            }
+        public int getSelectionEnd() {
+            return Math.max(caret.getDot(), caret.getMark());
+        }
 
-            public Rectangle getVisibleRect() {
-                return new Rectangle(-scrollPosition.x, -scrollPosition.y, w, h);
-            }
+        public Rectangle getVisibleRect() {
+            return new Rectangle(-scrollPosition.x, -scrollPosition.y, w, h);
+        }
 
-            public View getRootView() {
-                return rootViewContext.getView();
-            }
+        public View getRootView() {
+            return rootViewContext.getView();
+        }
 
-            public Rectangle modelToView(int pos) throws BadLocationException {
-                return modelToView(pos, Bias.Forward);
-            }
+        public Rectangle modelToView(int pos) throws BadLocationException {
+            return modelToView(pos, Bias.Forward);
+        }
 
-            public Rectangle modelToView(int pos, Bias bias)
-            throws BadLocationException {
-                Rectangle mRect = getModelRect();
-                if (mRect.isEmpty()) {
-                    return null;
-                }
-                Shape shape = getRootView().modelToView(pos, mRect, bias);
-                if (shape != null) {
-                    return shape.getBounds();
-                }
+        public Rectangle modelToView(int pos, Bias bias) throws BadLocationException {
+            Rectangle mRect = getModelRect();
+            if (mRect.isEmpty()) {
                 return null;
             }
-
-            public Component getComponent() {
-                return TextComponent.this;
-            }
-
-            public int viewToModel(Point p, Bias[] biasRet) {
-                return getRootView().viewToModel(p.x, p.y, getModelRect(), biasRet);
-            }
-
-            public void scrollRectToVisible(Rectangle rect) {
-                TextComponent.this.scrollRectToVisible(rect);
+            Shape shape = getRootView().modelToView(pos, mRect, bias);
+            if (shape != null) {
+                return shape.getBounds();
             }
+            return null;
+        }
 
-            public boolean isScrollBarArea(int x, int y) {
-                return false;
-            }
+        public Component getComponent() {
+            return TextComponent.this;
+        }
 
-            public void addCaretListeners(EventListener listener) {
-                // do nothing
+        public int viewToModel(Point p, Bias[] biasRet) {
+            return getRootView().viewToModel(p.x, p.y, getModelRect(), biasRet);
+        }
 
-            }
+        public void scrollRectToVisible(Rectangle rect) {
+            TextComponent.this.scrollRectToVisible(rect);
+        }
 
-            public void paintLayeredHighlights(Graphics g, int p0, int p1,
-                                               Shape shape, View view) {
-                caret.getHighlighter().paintLayeredHighlights(g, p0, p1,
-                                                              shape, view);
-            }
+        public boolean isScrollBarArea(int x, int y) {
+            return false;
+        }
 
-            public void revalidate() {
-                TextComponent.this.revalidate();
-            }
+        public void addCaretListeners(EventListener listener) {
+            // do nothing
+        }
 
-            public Color getDisabledTextColor() {
-                return SystemColor.textInactiveText;
-            }
+        public void paintLayeredHighlights(Graphics g, int p0, int p1, Shape shape, View view) {
+            caret.getHighlighter().paintLayeredHighlights(g, p0, p1, shape, view);
+        }
 
-            public Color getSelectedTextColor() {
-                return SystemColor.textHighlightText;
-            }
+        public void revalidate() {
+            TextComponent.this.revalidate();
+        }
 
-            public View create(Element element) {
-                // do nothing
-                return null;
-            }
+        public Color getDisabledTextColor() {
+            return SystemColor.textInactiveText;
+        }
 
-            public ViewFactory getViewFactory() {
-                return this;
-            }
+        public Color getSelectedTextColor() {
+            return SystemColor.textHighlightText;
         }
 
+        public View create(Element element) {
+            // do nothing
+            return null;
+        }
 
-    class State extends Component.ComponentState
-    implements TextComponentState {
+        public ViewFactory getViewFactory() {
+            return this;
+        }
+    }
 
+    class State extends Component.ComponentState implements TextComponentState {
         final Dimension textSize = new Dimension();
 
         public String getText() {
@@ -510,30 +474,33 @@
             return super.isEnabled() && isEditable();
         }
 
-        public Rectangle getClient() {            
+        public Rectangle getClient() {
             return TextComponent.this.getClient();
         }
 
-        public Insets getInsets() {            
+        public Insets getInsets() {
             return getNativeInsets();
         }
-
     }
 
     protected volatile transient TextListener textListener;
 
-    private final AWTListenerList textListeners = new AWTListenerList(this);
+    private final AWTListenerList<TextListener> textListeners = new AWTListenerList<TextListener>(
+            this);
 
     AbstractDocument document;
+
     final transient TextCaret caret;
+
     final transient RootViewContext rootViewContext;
 
     final Point scrollPosition = new Point();
+
     private boolean editable;
+
     private final Insets BORDER = new Insets(2, 2, 2, 2);
-    private final State state;
 
-//    StringBuffer text = new StringBuffer();
+    private final State state;
 
     TextComponent() {
         state = new State();
@@ -541,25 +508,19 @@
         dispatchToIM = true; // had been disabled by createBehavior()
         setFont(new Font("DialogInput", Font.PLAIN, 12)); // QUICK FIX
         document = new PlainDocument();
-
-//        text = new StringBuffer();
-
+        //        text = new StringBuffer();
         setTextKit(new TextKitImpl());
-
         rootViewContext = createRootViewContext();
         rootViewContext.getView().append(createView());
         rootViewContext.getView().setSize(w, h);
-
         caret = createCaret();
         setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
-
         addAWTMouseListener(getMouseHandler());
         addAWTMouseMotionListener(getMotionHandler());
-        addAWTFocusListener((FocusListener)caret);
+        addAWTFocusListener((FocusListener) caret);
         addAWTKeyListener(new KeyHandler());
         // document handler must be added after caret's listener has been added!
         document.addDocumentListener(new DocumentHandler());
-
     }
 
     /**
@@ -567,7 +528,7 @@
      * To be overridden.
      */
     MouseMotionListener getMotionHandler() {
-        return (MouseMotionListener)caret;
+        return (MouseMotionListener) caret;
     }
 
     /**
@@ -575,7 +536,7 @@
      * To be overridden.
      */
     MouseListener getMouseHandler() {
-        return (MouseListener)caret;
+        return (MouseListener) caret;
     }
 
     /**
@@ -594,14 +555,11 @@
      * @return this component's root view
      */
     private RootViewContext createRootViewContext() {
-
         TextFactory factory = TextFactory.getTextFactory();
         RootViewContext c = factory.createRootView(null);
-
         c.setComponent(this);
         c.setDocument(document);
-        c.setViewFactoryGetter((TextKitImpl)getTextKit());
-
+        c.setViewFactoryGetter((TextKitImpl) getTextKit());
         return c;
     }
 
@@ -631,14 +589,12 @@
 
     @Override
     public void addNotify() {
-//        toolkit.lockAWT();
-//        try {
-            super.addNotify();
-            
-            
-//        } finally {
-//            toolkit.unlockAWT();
-//        }
+        //        toolkit.lockAWT();
+        //        try {
+        super.addNotify();
+        //        } finally {
+        //            toolkit.unlockAWT();
+        //        }
         //      ajust caret position if was invalid
         int maxPos = document.getLength();
         if (getCaretPosition() > maxPos) {
@@ -673,13 +629,11 @@
          * which can be revealed by the following code:
          * System.out.println(new TextField());
          */
-
         toolkit.lockAWT();
         try {
-            return (super.paramString() + ",text=" + getText() +
-                    (isEditable() ? ",editable" : "") +
-                    ",selection=" + getSelectionStart() +
-                    "-" + getSelectionEnd());
+            return (super.paramString() + ",text=" + getText()
+                    + (isEditable() ? ",editable" : "") + ",selection=" + getSelectionStart()
+                    + "-" + getSelectionEnd());
         } finally {
             toolkit.unlockAWT();
         }
@@ -725,7 +679,8 @@
             try {
                 int length = getSelectionEnd() - getSelectionStart();
                 s = document.getText(getSelectionStart(), length);
-            } catch (final BadLocationException e) { }
+            } catch (final BadLocationException e) {
+            }
             return s;
         } finally {
             toolkit.unlockAWT();
@@ -822,40 +777,40 @@
     }
 
     public void setSelectionEnd(int selectionEnd) {
-//        toolkit.lockAWT();
-//        try {
-            selectionEnd = Math.min(selectionEnd, document.getLength());
-            int start = getSelectionStart();
-            if (selectionEnd < start) {
-                caret.setDot(selectionEnd, caret.getDotBias());
-            } else {
-               caret.setDot(start, caret.getDotBias());
-               caret.moveDot(Math.max(start, selectionEnd), caret.getDotBias());
-            }
-//        } finally {
-//            toolkit.unlockAWT();
-//        }
+        //        toolkit.lockAWT();
+        //        try {
+        selectionEnd = Math.min(selectionEnd, document.getLength());
+        int start = getSelectionStart();
+        if (selectionEnd < start) {
+            caret.setDot(selectionEnd, caret.getDotBias());
+        } else {
+            caret.setDot(start, caret.getDotBias());
+            caret.moveDot(Math.max(start, selectionEnd), caret.getDotBias());
+        }
+        //        } finally {
+        //            toolkit.unlockAWT();
+        //        }
     }
 
     public void setSelectionStart(int selectionStart) {
-//        toolkit.lockAWT();
-//        try {
-            selectionStart = Math.max(selectionStart, 0);
-            int end = getSelectionEnd();
-            if (selectionStart > end) {
-                caret.setDot(selectionStart, caret.getDotBias());
-            } else {
-               caret.setDot(end, caret.getDotBias());
-               caret.moveDot(Math.min(end, selectionStart), caret.getDotBias());
-            }
-//        } finally {
-//            toolkit.unlockAWT();
-//        }
+        //        toolkit.lockAWT();
+        //        try {
+        selectionStart = Math.max(selectionStart, 0);
+        int end = getSelectionEnd();
+        if (selectionStart > end) {
+            caret.setDot(selectionStart, caret.getDotBias());
+        } else {
+            caret.setDot(end, caret.getDotBias());
+            caret.moveDot(Math.min(end, selectionStart), caret.getDotBias());
+        }
+        //        } finally {
+        //            toolkit.unlockAWT();
+        //        }
     }
 
     public void setText(String text) {
         toolkit.lockAWT();
-        try {            
+        try {
             if (text == null) {
                 text = "";
             }
@@ -873,11 +828,12 @@
                 // return caret back to emulate "no movement"
                 caret.setDot(oldCaretPos, caret.getDotBias());
             }
-        } catch (BadLocationException e) {            
+        } catch (BadLocationException e) {
             e.printStackTrace();
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         if (TextListener.class.isAssignableFrom(listenerType)) {
@@ -890,7 +846,6 @@
         textListeners.addUserListener(l);
         // for compatibility only:
         textListener = AWTEventMulticaster.add(textListener, l);
-
     }
 
     public void removeTextListener(TextListener l) {
@@ -900,7 +855,7 @@
     }
 
     public TextListener[] getTextListeners() {
-        return (TextListener[]) textListeners.getUserListeners(new TextListener[0]);
+        return textListeners.getUserListeners(new TextListener[0]);
     }
 
     @Override
@@ -913,13 +868,11 @@
     }
 
     protected void processTextEvent(TextEvent e) {
-        for (Iterator<?> i = textListeners.getUserIterator(); i.hasNext();) {
-            TextListener listener = (TextListener) i.next();
-
+        for (TextListener listener : textListeners.getUserListeners()) {
             switch (e.getID()) {
-            case TextEvent.TEXT_VALUE_CHANGED:
-                listener.textValueChanged(e);
-                break;
+                case TextEvent.TEXT_VALUE_CHANGED:
+                    listener.textValueChanged(e);
+                    break;
             }
         }
     }
@@ -937,10 +890,8 @@
         if ((viewSize.height <= 0) || (viewSize.width <= 0)) {
             return; // FIX
         }
-
         int dx;
         int dy;
-
         r.x -= ins.left;
         r.y -= ins.top;
         if (r.x > 0) {
@@ -960,7 +911,6 @@
         } else {
             dx = 0;
         }
-
         if (r.y > 0) {
             if (r.y + r.height > viewSize.height) {
                 int dy2 = r.y + r.height - viewSize.height;
@@ -978,13 +928,10 @@
         } else {
             dy = 0;
         }
-
         if (dx != 0 || dy != 0) {
             int x = viewPos.x + dx;
             int y = viewPos.y + dy;
-
             Point point = new Point(x, y);
-
             setViewPosition(point);
             repaint();
         }
@@ -997,7 +944,7 @@
     void setViewPosition(Point point) {
         scrollPosition.setLocation(-point.x, -point.y);
     }
-    
+
     /**
      * Gets current scroll position
      */
@@ -1007,9 +954,8 @@
 
     Rectangle getClient() {
         Insets insets = getInsets();
-        return new Rectangle(insets.left, insets.top,
-                w - insets.right - insets.left,
-                h - insets.top - insets.bottom);
+        return new Rectangle(insets.left, insets.top, w - insets.right - insets.left, h
+                - insets.top - insets.bottom);
     }
 
     /**
@@ -1032,15 +978,10 @@
 
     @Override
     void prepaint(Graphics g) {
-
         toolkit.theme.drawTextComponentBackground(g, state);
-
         g.setFont(getFont());
-        g.setColor(isEnabled() ? getForeground() :
-                   SystemColor.textInactiveText);
-
+        g.setColor(isEnabled() ? getForeground() : SystemColor.textInactiveText);
         Rectangle r = getModelRect();
-
         rootViewContext.getView().setSize(r.width, r.height);
         Rectangle client = getClient();
         Shape oldClip = g.getClip();
@@ -1072,7 +1013,6 @@
         bi.setText(getText());
         int end = bi.following(index);
         int start = bi.preceding(end - 1);
-
         try {
             result = document.getText(start, end - start);
         } catch (BadLocationException e) {
@@ -1091,7 +1031,6 @@
             result = document.getText(start, length);
         } catch (final BadLocationException e) {
         }
-
         return result;
     }
 
@@ -1105,7 +1044,6 @@
     }
 
     private int getWordEnd(final int pos) throws BadLocationException {
-
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = document.getLength();
         if (pos < 0 || pos > length) {
@@ -1116,16 +1054,13 @@
         return (pos < bi.last()) ? bi.following(pos) : pos;
     }
 
-    private int getWordStart(final int pos)
-            throws BadLocationException {
-
+    private int getWordStart(final int pos) throws BadLocationException {
         BreakIterator bi = BreakIterator.getWordInstance();
         int length = document.getLength();
         if (pos < 0 || pos > length) {
             throwException("No word at " + pos, pos);
         }
         String content = null;
-
         content = document.getText(0, length);
         bi.setText(content);
         int iteratorWordStart = pos;
@@ -1138,24 +1073,22 @@
         return iteratorWordStart;
     }
 
-    private static void throwException(final String s, final int i)
-            throws BadLocationException {
+    private static void throwException(final String s, final int i) throws BadLocationException {
         throw new BadLocationException(s, i);
     }
 
     @Override
-    void setEnabledImpl(boolean value) {        
+    void setEnabledImpl(boolean value) {
         super.setEnabledImpl(value);
         if (isShowing()) {
             repaint();
         }
     }
-    
+
     @Override
     void postprocessEvent(AWTEvent e, long eventMask) {
         // have to call system listeners without AWT lock
         // to avoid deadlocks in code common with UI text
-        
         if (eventMask == AWTEvent.FOCUS_EVENT_MASK) {
             preprocessFocusEvent((FocusEvent) e);
         } else if (eventMask == AWTEvent.KEY_EVENT_MASK) {
@@ -1168,9 +1101,8 @@
             super.postprocessEvent(e, eventMask);
         }
     }
-    
+
     void performTextAction(AWTTextAction action) {
         action.performAction(getTextKit());
     }
-    
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextField.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextField.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextField.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TextField.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.ActionEvent;
@@ -25,8 +22,6 @@
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.util.EventListener;
-import java.util.Iterator;
-
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
@@ -35,7 +30,6 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.text.View;
-
 import org.apache.harmony.awt.text.AWTTextAction;
 import org.apache.harmony.awt.text.ActionNames;
 import org.apache.harmony.awt.text.ActionSet;
@@ -43,11 +37,8 @@
 import org.apache.harmony.awt.text.TextFactory;
 import org.apache.harmony.awt.text.TextFieldKit;
 
-
 public class TextField extends TextComponent {
-
     protected class AccessibleAWTTextField extends AccessibleAWTTextComponent {
-
         private static final long serialVersionUID = 6219164359235943158L;
 
         @Override
@@ -56,15 +47,12 @@
             set.add(AccessibleState.SINGLE_LINE);
             return set;
         }
-
-
     }
 
     /**
      * Implementation of text field specific text operations
      */
     final class TextFieldKitImpl implements TextFieldKit {
-
         /**
          * used in horizontal text scrolling
          */
@@ -82,12 +70,10 @@
          */
         public BoundedRangeModel getHorizontalVisibility() {
             if (boundedRangeModel == null) {
-                int prefWidth = (int) rootViewContext.getView().
-                                getPreferredSpan(View.X_AXIS);
+                int prefWidth = (int) rootViewContext.getView().getPreferredSpan(View.X_AXIS);
                 int value = getMaxScrollOffset();
                 int max = Math.max(prefWidth, value);
                 boundedRangeModel = new DefaultBoundedRangeModel(value, max - value, 0, max);
-
                 boundedRangeModel.addChangeListener(new ChangeListener() {
                     public void stateChanged(ChangeEvent e) {
                         scrollPosition.x = -boundedRangeModel.getValue();
@@ -108,17 +94,16 @@
         public Insets getInsets() {
             return TextField.this.getNativeInsets();
         }
-
     }
 
     private static final long serialVersionUID = -2966288784432217853L;
 
-    private final AWTListenerList actionListeners = new AWTListenerList(this);
-
-    private int columns = 0;
+    private final AWTListenerList<ActionListener> actionListeners = new AWTListenerList<ActionListener>(
+            this);
 
-    private char echoChar = 0;
+    private int columns;
 
+    private char echoChar;
 
     public TextField(String text) throws HeadlessException {
         this(text, (text != null ? text.length() : 0));
@@ -152,13 +137,13 @@
         toolkit.lockAWT();
         try {
             Toolkit.checkHeadless();
-            setTextFieldKit(new TextFieldKitImpl());            
+            setTextFieldKit(new TextFieldKitImpl());
             this.columns = Math.max(0, columns);
             addAWTKeyListener(new KeyAdapter() {
                 @Override
                 public void keyPressed(KeyEvent e) {
-                    if ((e.getKeyCode() == KeyEvent.VK_ENTER) &&
-                        !e.isAltDown() && !e.isControlDown()) {
+                    if ((e.getKeyCode() == KeyEvent.VK_ENTER) && !e.isAltDown()
+                            && !e.isControlDown()) {
                         generateActionEvent(e.getWhen(), e.getModifiers());
                     }
                 }
@@ -174,7 +159,7 @@
         document.putProperty(PropertyNames.FILTER_NEW_LINES, Boolean.TRUE);
         setText(getText()); // remove all new lines in already existing text
         toolkit.lockAWT();
-        try {            
+        try {
             super.addNotify();
         } finally {
             toolkit.unlockAWT();
@@ -265,7 +250,6 @@
             return null;
         }
         return new Dimension(fm.charWidth('_') * cols + 6, fm.getHeight() + 6);
-
     }
 
     /**
@@ -280,7 +264,6 @@
             if ((columns > 0)) {
                 return minimumSize(columns);
             }
-
             return super.minimumSize();
         } finally {
             toolkit.unlockAWT();
@@ -296,7 +279,6 @@
          * tf.setEchoChar('q');
          * System.out.println(tf);
          */
-
         toolkit.lockAWT();
         try {
             String paramStr = super.paramString();
@@ -339,7 +321,6 @@
             if (columns > 0) {
                 return preferredSize(columns);
             }
-
             return super.preferredSize();
         } finally {
             toolkit.unlockAWT();
@@ -394,14 +375,12 @@
         repaint();
     }
 
-    /**
-     * @deprecated
-     */
     @Deprecated
     public void setEchoCharacter(char ch) {
         setEchoChar(ch);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         if (ActionListener.class.isAssignableFrom(listenerType)) {
@@ -419,7 +398,7 @@
     }
 
     public ActionListener[] getActionListeners() {
-        return (ActionListener[]) actionListeners.getUserListeners(new ActionListener[0]);
+        return actionListeners.getUserListeners(new ActionListener[0]);
     }
 
     @Override
@@ -432,13 +411,11 @@
     }
 
     protected void processActionEvent(ActionEvent e) {
-        for (Iterator i = actionListeners.getUserIterator(); i.hasNext();) {
-            ActionListener listener = (ActionListener) i.next();
-
+        for (ActionListener listener : actionListeners.getUserListeners()) {
             switch (e.getID()) {
-            case ActionEvent.ACTION_PERFORMED:
-                listener.actionPerformed(e);
-                break;
+                case ActionEvent.ACTION_PERFORMED:
+                    listener.actionPerformed(e);
+                    break;
             }
         }
     }
@@ -470,13 +447,11 @@
             return null;
         }
         return getDefaultMinimumSize();
-
     }
 
     private void generateActionEvent(long when, int modifiers) {
-        postEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
-                                  getText(), when, modifiers));
-
+        postEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getText(), when,
+                modifiers));
     }
 
     /**
@@ -500,7 +475,6 @@
             brm.setValue(oldValue - (insets.left - x) - 2);
             repaint();
         }
-
     }
 
     /**
@@ -519,8 +493,8 @@
      */
     final int getMaxScrollOffset() {
         Insets ins = getNativeInsets();
-        int prefWidth = (int) rootViewContext.getView().
-        getPreferredSpan(View.X_AXIS) + ins.left + ins.right;
+        int prefWidth = (int) rootViewContext.getView().getPreferredSpan(View.X_AXIS)
+                + ins.left + ins.right;
         int width = getWidth();
         int diff = prefWidth - width;
         return (diff >= 0) ? diff + 1 : 0;
@@ -530,12 +504,12 @@
     AccessibleContext createAccessibleContext() {
         return new AccessibleAWTTextField();
     }
-    
+
     @Override
-    String autoName() {        
+    String autoName() {
         return ("textfield" + toolkit.autoNumber.nextTextField++);
     }
-    
+
     /**
      * Handles text actions.
      * Ignores new line insertion into text.
@@ -546,5 +520,4 @@
             super.performTextAction(action);
         }
     }
-    
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java Sat Oct  7 16:10:23 2006
@@ -14,14 +14,10 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Denis M. Kishenko
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
@@ -29,18 +25,13 @@
 import java.awt.image.DataBufferByte;
 import java.awt.image.DataBufferInt;
 import java.awt.image.DataBufferUShort;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
-
-import org.apache.harmony.awt.gl.AwtImageBackdoorAccessor;
 
 public class TexturePaint implements Paint {
-
     /**
      * The BufferedImage object used as texture  
      */
     BufferedImage img;
-    
+
     /**
      * The Rectangle2D bounds of texture piece to be painted  
      */
@@ -55,33 +46,29 @@
         return img;
     }
 
-    public PaintContext createContext(ColorModel cm, Rectangle device, Rectangle2D user, AffineTransform t, RenderingHints hints) {
+    public PaintContext createContext(ColorModel cm, Rectangle device, Rectangle2D user,
+            AffineTransform t, RenderingHints hints) {
         Object value = hints.get(RenderingHints.KEY_INTERPOLATION);
-        boolean bilinear = (value != null) && (value != RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
-
+        boolean bilinear = (value != null)
+                && (value != RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
         int type = img.getType();
         DataBuffer buf = img.getRaster().getDataBuffer();
         if (buf instanceof DataBufferInt) {
-            if (type == BufferedImage.TYPE_INT_ARGB ||
-                type == BufferedImage.TYPE_INT_ARGB_PRE ||
-                type == BufferedImage.TYPE_INT_BGR ||
-                type == BufferedImage.TYPE_INT_RGB)
-            {
+            if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_ARGB_PRE
+                    || type == BufferedImage.TYPE_INT_BGR || type == BufferedImage.TYPE_INT_RGB) {
                 if (bilinear) {
                     return new TexturePaintContext.IntBilinear(img, anchor, t);
                 }
                 return new TexturePaintContext.IntSimple(img, anchor, t);
             }
-        } else
-        if (buf instanceof DataBufferByte) {
+        } else if (buf instanceof DataBufferByte) {
             if (type == BufferedImage.TYPE_BYTE_GRAY) {
                 if (bilinear) {
                     return new TexturePaintContext.ByteBilinear(img, anchor, t);
                 }
                 return new TexturePaintContext.ByteSimple(img, anchor, t);
             }
-        } else
-        if (buf instanceof DataBufferUShort) {
+        } else if (buf instanceof DataBufferUShort) {
             if (type == BufferedImage.TYPE_USHORT_GRAY) {
                 if (bilinear) {
                     return new TexturePaintContext.ShortBilinear(img, anchor, t);
@@ -106,5 +93,4 @@
     public Rectangle2D getAnchorRect() {
         return anchor;
     }
-
 }