tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / ScrollView.java
index 59b66646288549114fab0e3a41cff2a26615fefd..c9c6f33fa1cd63596e0567132da7dee7ab59f313 100755 (executable)
@@ -1,16 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- * 
+ * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors: 
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
 
 import java.util.Timer;
@@ -51,19 +50,19 @@ import org.eclipse.swt.widgets.Scrollable;
 import org.eclipse.swt.widgets.Shell;
 
 /**
- * ScrollView widget provides a scrolling area with on-demand scroll bars. 
+ * ScrollView widget provides a scrolling area with on-demand scroll bars.
  * Overview scrollable panel can be used (@see setOverviewEnabled()).
- * 
+ *
  * @author Eric Miravete
  * @version 1.0
  */
 public class ScrollView extends Composite {
-    
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
 
-    // Value for scroll bar mode, default is AUTO 
+    // Value for scroll bar mode, default is AUTO
     /**
      * Scroll bar mode AUTO
      */
@@ -77,11 +76,11 @@ public class ScrollView extends Composite {
      */
     public static final int ALWAYS_OFF = 2;
     /**
-     * Bit mask for visible vertical scroll bar  
+     * Bit mask for visible vertical scroll bar
      */
     public static final int VBAR = 0x01;
     /**
-     * Bit mask for visible horizontal scroll bar  
+     * Bit mask for visible horizontal scroll bar
      */
     public static final int HBAR = 0x02;
     /**
@@ -93,20 +92,20 @@ public class ScrollView extends Composite {
      */
     protected int fContentsWidth = 0;
     /**
-     * Value of the contents x coordinate property 
+     * Value of the contents x coordinate property
      */
     protected int fContentsX = 0;
     /**
-     * Value of the contents y coordinate property 
+     * Value of the contents y coordinate property
      */
     protected int fContentsY = 0;
     /**
-     * Scroll bar mode of horizontal scroll bar. 
-     */    
+     * Scroll bar mode of horizontal scroll bar.
+     */
     protected int fHorScrollbarMode = AUTO;
     /**
-     * Scroll bar mode of vertical scroll bar. 
-     */    
+     * Scroll bar mode of vertical scroll bar.
+     */
     protected int fVertScrollbarMode = AUTO;
     /**
      * Increment for the horizontal scroll bar.
@@ -158,7 +157,7 @@ public class ScrollView extends Composite {
      */
     protected Canvas fViewControl;
     /**
-     * Control used in the bottom right corner @see setCornerControl() and @see setOverviewEnabled(true) 
+     * Control used in the bottom right corner @see setCornerControl() and @see setOverviewEnabled(true)
      */
     protected Control fCornerControl;
     /**
@@ -166,23 +165,23 @@ public class ScrollView extends Composite {
      */
     protected int fOverviewSize = 100; // default size for overview
     /**
-     * Timer for auto_scroll feature 
+     * Timer for auto_scroll feature
      */
     protected AutoScroll fAutoScroll = null;
-    /** 
-     * TimerTask for auto_scroll feature !=null when auto scroll is running 
+    /**
+     * TimerTask for auto_scroll feature !=null when auto scroll is running
      */
     protected Timer fAutoScrollTimer = null;
-    /** 
-     * where mouse down appear on contents area (x coordinate) 
+    /**
+     * where mouse down appear on contents area (x coordinate)
      */
     protected int fMouseDownX = -1;
-    /** 
-     * where mouse down appear on contents area (y coordinate) 
+    /**
+     * where mouse down appear on contents area (y coordinate)
      */
     protected int fMousDownY = -1;
 
-    
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -190,7 +189,7 @@ public class ScrollView extends Composite {
     /**
      * Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled
      * using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).
-     * 
+     *
      * @param c The parent composite
      * @param style The SWT style bits @see SWT
      */
@@ -201,7 +200,7 @@ public class ScrollView extends Composite {
     /**
      * Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled
      * using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).
-     * 
+     *
      * @param c The parent composite.
      * @param style The SWT style bits @see SWT
      * @param mouseWheel Flag to force scrollView to handles mouse wheel
@@ -356,7 +355,7 @@ public class ScrollView extends Composite {
             }
         });
 
-        if (fViewControl.getVerticalBar() != null)
+        if (fViewControl.getVerticalBar() != null) {
             // add fViewControl hidden scrollbar listener to get mouse wheel ...
             fViewControl.getVerticalBar().addSelectionListener(new SelectionListener() {
                 @Override
@@ -371,6 +370,7 @@ public class ScrollView extends Composite {
                 public void widgetDefaultSelected(SelectionEvent e) {
                 }
             });
+        }
         getHorizontalBar().addSelectionListener(new SelectionListener() {
             @Override
             public void widgetSelected(SelectionEvent e) {
@@ -386,7 +386,7 @@ public class ScrollView extends Composite {
             public void widgetDefaultSelected(SelectionEvent e) {
             }
         });
-        if (fViewControl.getHorizontalBar() != null)
+        if (fViewControl.getHorizontalBar() != null) {
             fViewControl.getHorizontalBar().addSelectionListener(new SelectionListener() {
                 @Override
                 public void widgetSelected(SelectionEvent e) {
@@ -400,36 +400,23 @@ public class ScrollView extends Composite {
                 public void widgetDefaultSelected(SelectionEvent e) {
                 }
             });
+        }
     }
 
     // ------------------------------------------------------------------------
     // Methods
     // ------------------------------------------------------------------------
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Composite#setFocus()
-     */
     @Override
     public boolean setFocus() {
         return fViewControl.forceFocus();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Control#setCursor(org.eclipse.swt.graphics.Cursor)
-     */
     @Override
     public void setCursor(Cursor cursor) {
         fViewControl.setCursor(cursor);
     }
 
-    /*
-     * Dispose controls used in scroll view
-     * 
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Widget#dispose()
-     */
     @Override
     public void dispose() {
         if (fAutoScroll != null) {
@@ -459,29 +446,17 @@ public class ScrollView extends Composite {
         super.dispose();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Composite#getClientArea()
-     */
     @Override
     public Rectangle getClientArea() {
         return fViewControl.getClientArea();
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
-     */
     @Override
     public void setBackground(Color c) {
         super.setBackground(c);
         fViewControl.setBackground(c);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Control#setToolTipText(java.lang.String)
-     */
     @Override
     public void setToolTipText(String text) {
         fViewControl.setToolTipText(text);
@@ -491,7 +466,7 @@ public class ScrollView extends Composite {
      * Draw overview area, @see setOverviewEnabled. By default draw a rectangle corresponding to the visible area of
      * scroll view. You can redefine this method to draw the contents as drawContents does... ...in an other magnify
      * factor.
-     * 
+     *
      * @param gc GC to used to draw.
      * @param r Rectangle corresponding to the client area of overview.
      */
@@ -522,7 +497,7 @@ public class ScrollView extends Composite {
 
     /**
      * Remove the local Listener and add the new listener.
-     * 
+     *
      * @param nlistener the new listener
      */
     public void replaceControlListener(ControlListener nlistener) {
@@ -535,7 +510,7 @@ public class ScrollView extends Composite {
 
     /**
      * Remove the local Listener and add the new listener.
-     * 
+     *
      * @param nlistener the new listener
      */
     public void replaceKeyListener(KeyListener nlistener) {
@@ -548,7 +523,7 @@ public class ScrollView extends Composite {
 
     /**
      * Remove the local Listener and add the new listener.
-     * 
+     *
      * @param nlistener the new listener
      */
     public void replaceMouseListener(MouseListener nlistener) {
@@ -561,7 +536,7 @@ public class ScrollView extends Composite {
 
     /**
      * Remove the local Listener and add the new listener.
-     * 
+     *
      * @param nlistener the new listener
      */
     public void replaceMouseMoveListener(MouseMoveListener nlistener) {
@@ -574,7 +549,7 @@ public class ScrollView extends Composite {
 
     /**
      * Remove the local Listener and add the new listener.
-     * 
+     *
      * @param nlistener the new listener
      */
     public void replacePaintListener(PaintListener nlistener) {
@@ -587,7 +562,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the contentsHeight property.
-     * 
+     *
      * @return the current value of the contentsHeight property
      */
     public int getContentsHeight() {
@@ -596,7 +571,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the contentsWidth property.
-     * 
+     *
      * @return the current value of the contentsWidth property
      */
     public int getContentsWidth() {
@@ -605,7 +580,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the contentsX property.
-     * 
+     *
      * @return the current value of the contentsX property
      */
     public int getContentsX() {
@@ -614,7 +589,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the contentsY property.
-     * 
+     *
      * @return the current value of the contentsY property
      */
     public int getContentsY() {
@@ -623,16 +598,16 @@ public class ScrollView extends Composite {
 
     /**
      * Determines if the dragAutoScroll property is true.
-     * 
+     *
      * @return <code>true<code> if the dragAutoScroll property is true
      */
-    public boolean getDragAutoScroll() {
+    public boolean isDragAutoScroll() {
         return fAutoScrollEnabled;
     }
 
     /**
      * Sets the value of the dragAutoScroll property.
-     * 
+     *
      * @param aDragAutoScroll the new value of the dragAutoScroll property
      */
     public void setDragAutoScroll(boolean aDragAutoScroll) {
@@ -645,7 +620,7 @@ public class ScrollView extends Composite {
 
     /**
      * Change delay (in millisec) used for auto scroll feature.
-     * 
+     *
      * @param period new period between to auto scroll
      */
     public void setDragAutoScrollPeriod(int period) {
@@ -654,6 +629,8 @@ public class ScrollView extends Composite {
 
     /**
      * Return auto scroll period.
+     *
+     * @return The period
      */
     public int getDragAutoScrollPeriod() {
         return fAutoScrollPeriod;
@@ -661,7 +638,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the hScrollBarMode property.
-     * 
+     *
      * @return the current value of the hScrollBarMode property
      */
     public int getHScrollBarMode() {
@@ -670,7 +647,7 @@ public class ScrollView extends Composite {
 
     /**
      * Sets the value of the hScrollBarMode property.
-     * 
+     *
      * @param aHScrollBarMode the new value of the hScrollBarMode property
      */
     public void setHScrollBarMode(int aHScrollBarMode) {
@@ -679,7 +656,7 @@ public class ScrollView extends Composite {
 
     /**
      * Access method for the vScrollBarMode property.
-     * 
+     *
      * @return the current value of the vScrollBarMode property
      */
     public int getVScrollBarMode() {
@@ -688,7 +665,7 @@ public class ScrollView extends Composite {
 
     /**
      * Sets the value of the vScrollBarMode property.
-     * 
+     *
      * @param aVScrollBarMode the new value of the vScrollBarMode property
      */
     public void setVScrollBarMode(int aVScrollBarMode) {
@@ -697,6 +674,8 @@ public class ScrollView extends Composite {
 
     /**
      * Return horizontal scroll bar increment, default:1
+     *
+     * @return The increment
      */
     public int getHScrollBarIncrement() {
         return fHorScrollbarIncrement;
@@ -704,20 +683,30 @@ public class ScrollView extends Composite {
 
     /**
      * Return vertical scroll bar increment, default:1
+     *
+     * @return The increment
      */
     public int getVScrollBarIncrement() {
         return fVertScrollbarIncrement;
     }
 
     /**
-     * Change horizontal scroll bar increment, minimum:1. Page increment is always set to visible width.
+     * Change horizontal scroll bar increment, minimum:1. Page increment is
+     * always set to visible width.
+     *
+     * @param inc
+     *            Increment value to set
      */
     public void setHScrollBarIncrement(int inc) {
         fHorScrollbarIncrement = Math.max(1, inc);
     }
 
     /**
-     * Change vertical scroll bar increment, minimum:1. Page increment is always set to visible height.
+     * Change vertical scroll bar increment, minimum:1. Page increment is always
+     * set to visible height.
+     *
+     * @param inc
+     *            Increment value to set
      */
     public void setVScrollBarIncrement(int inc) {
         fVertScrollbarIncrement = Math.max(1, inc);
@@ -727,11 +716,11 @@ public class ScrollView extends Composite {
      * Enable or disable overview feature. Enabling overview, dispose and replace existing corner control by a button.
      * Clicking in it open overview, move mouse cursor holding button to move scroll view and release button to hide
      * overview. Tip: hold control and/or shift key while moving mouse when overview is open made fine scroll.
-     * 
+     *
      * @param value true to engage overview feature
      */
     public void setOverviewEnabled(boolean value) {
-        if (getOverviewEnabled() == value) {
+        if (isOverviewEnabled() == value) {
             return;
         }
 
@@ -750,6 +739,9 @@ public class ScrollView extends Composite {
 
     /**
      * Change overview size (at ratio 1:1), default is 100
+     *
+     * @param size
+     *            The new size
      */
     public void setOverviewSize(int size) {
         fOverviewSize = Math.abs(size);
@@ -757,10 +749,10 @@ public class ScrollView extends Composite {
 
     /**
      * Returns whether the overview is enabled or not.
-     * 
+     *
      * @return true is overview feature is enabled
      */
-    public boolean getOverviewEnabled() {
+    public boolean isOverviewEnabled() {
         if (fCornerControl instanceof Button) {
             Object data = ((Button) fCornerControl).getData();
             // overview alreay
@@ -773,7 +765,7 @@ public class ScrollView extends Composite {
 
     /**
      * Returns the overview size at ratio 1:1.
-     * 
+     *
      * @return current overview size at ratio 1:1
      */
     public int getOverviewSize() {
@@ -783,8 +775,8 @@ public class ScrollView extends Composite {
     /**
      * Returns control used to display view (might not be this object). Use this control to add/remove listener on the
      * draw area.
-     * 
-     * @return control used to display view (might not be this object). 
+     *
+     * @return control used to display view (might not be this object).
      */
     public Control getViewControl() {
         return fViewControl;
@@ -792,54 +784,76 @@ public class ScrollView extends Composite {
 
     /**
      * Called when the mouse enter the ScrollView area
-     * 
+     *
      * @param e
+     *            Mouse event
      */
     protected void contentsMouseExit(MouseEvent e) {
     }
 
     /**
-     * Called when the mouse enter the ScrollView area after and system defined time
-     * 
+     * Called when the mouse enter the ScrollView area after and system defined
+     * time
+     *
      * @param e
+     *            Mouse event
      */
     protected void contentsMouseHover(MouseEvent e) {
     }
 
     /**
      * Called when the mouse enter the ScrollView area
-     * 
+     *
      * @param e
+     *            Mouse event
      */
     protected void contentsMouseEnter(MouseEvent e) {
     }
 
     /**
      * Called when user double on contents area.
-     * 
+     *
      * @param e
+     *            Mouse event
      */
     protected void contentsMouseDoubleClickEvent(MouseEvent e) {
     }
 
     /**
      * Called when mouse is on contents area and button is pressed.
-     * 
+     *
      * @param e
+     *            Mouse event
      */
     protected void contentsMouseDownEvent(MouseEvent e) {
         fMouseDownX = e.x;
         fMousDownY = e.y;
     }
 
-    /** 
-     * TimerTask for auto scroll feature. 
+    /**
+     * TimerTask for auto scroll feature.
      */
     protected static class AutoScroll extends TimerTask {
+
+        /** X delta */
         public int deltaX;
+
+        /** Y delta */
         public int deltaY;
+
+        /** ScrollView object */
         public ScrollView scrollView;
 
+        /**
+         * Constructor.
+         *
+         * @param sv
+         *            ScrollView object to use
+         * @param dx
+         *            X delta
+         * @param dy
+         *            Y delta
+         */
         public AutoScroll(ScrollView sv, int dx, int dy) {
             scrollView = sv;
             deltaX = dx;
@@ -859,8 +873,9 @@ public class ScrollView extends Composite {
 
     /**
      * Called when mouse is on contents area and mode.
-     * 
+     *
      * @param event
+     *            Mouse event
      */
     protected void contentsMouseMoveEvent(MouseEvent event) {
         if ((event.stateMask & SWT.BUTTON_MASK) != 0) {
@@ -915,8 +930,9 @@ public class ScrollView extends Composite {
 
     /**
      * Called when mouse is on contents area and button is released
-     * 
+     *
      * @param event
+     *            Mouse event
      */
     protected void contentsMouseUpEvent(MouseEvent event) {
         // reset auto scroll if it's engaged
@@ -927,29 +943,34 @@ public class ScrollView extends Composite {
     }
 
     /**
-     * Responsible to draw contents area. At least rectangle clipX must be redrawn. This rectangle is given in contents
-     * coordinates. By default, no paint is produced.
-     * 
+     * Responsible to draw contents area. At least rectangle clipX must be
+     * redrawn. This rectangle is given in contents coordinates. By default, no
+     * paint is produced.
+     *
      * @param gc
+     *            Graphics context
      * @param clipx
+     *            X clip
      * @param clipy
+     *            Y clip
      * @param clipw
+     *            W clip
      * @param cliph
+     *            H clip
      */
     protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
     }
 
     /**
      * Change the size of the contents area.
-     * 
+     *
      * @param width new width of the area.
      * @param height new height of the area.
      */
     public void resizeContents(int width, int height) {
-        // System.out.println("SV--resizeContents("+_w+","+_h+" ) {");
         int localWidth = width;
         int localHeight = height;
-        
+
         if (localWidth < 0) {
             localWidth = 0;
         }
@@ -964,7 +985,6 @@ public class ScrollView extends Composite {
             return;
         }
 
-        // System.out.println("RESIZE-CONTENTS("+_w+","+_h+")");
         fContentsWidth = localWidth;
         fContentsHeight = localHeight;
 
@@ -1000,7 +1020,6 @@ public class ScrollView extends Composite {
         } else {
             updateScrollBarsValues();
         }
-        // System.out.println("SV--resizeContents() }");
     }
 
     // redefined for internal use ..
@@ -1012,7 +1031,7 @@ public class ScrollView extends Composite {
     }
 
     /**
-     * @param delataX The delta in X 
+     * @param delataX The delta in X
      * @param deltaY the delta in Y
      */
     public void scrollBy(int delataX, int deltaY) {
@@ -1021,7 +1040,7 @@ public class ScrollView extends Composite {
 
     /**
      * Scroll to ensure point(in contents coordinates) is visible.
-     * 
+     *
      * @param px Point's x position
      * @param py Point's y position
      */
@@ -1045,7 +1064,7 @@ public class ScrollView extends Composite {
     /**
      * Make rectangle (x,y,w,h, in contents coordinates) visible. if rectangle cannot be completely visible, use
      * align flags.
-     * 
+     *
      * @param xValue x contents coordinates of rectangle.
      * @param yValue y contents coordinates of rectangle.
      * @param width width of rectangle.
@@ -1060,7 +1079,7 @@ public class ScrollView extends Composite {
     /**
      * Make rectangle (xValue,yValue,width,height, in contents coordinates) visible. if rectangle cannot be completely visible, use
      * align flags.
-     * 
+     *
      * @param xValue x contents coordinates of rectangle.
      * @param yValue y contents coordinates of rectangle.
      * @param width width of rectangle.
@@ -1070,34 +1089,37 @@ public class ScrollView extends Composite {
      * @param forceAlign force alignment for rectangle smaller than the visible area
      */
     protected void ensureVisible(int xValue, int yValue, int width, int height, int align, boolean forceAlign) {
-        
+
+        int localX = xValue;
+        int localY = yValue;
         int localWidth = width;
         int localHeight = height;
 
         if (localWidth < 0) {
-            xValue = xValue + localWidth;
+            localX = localX + localWidth;
             localWidth = -localWidth;
         }
         if (localHeight < 0) {
-            yValue = yValue + localHeight;
+            localY = localY + localHeight;
             localHeight = -localHeight;
         }
         int hbar = getHorizontalBarHeight();
         int vbar = getVerticalBarWidth();
-        int cx = getContentsX(), cy = getContentsY();
+        int cx = getContentsX();
+        int cy = getContentsY();
         int right = getContentsX() + getVisibleWidth() - vbar;
         int bottom = getContentsY() + getVisibleHeight() - hbar;
         boolean align_h = false, align_v = false;
 
-        if (xValue < getContentsX()) {
-            cx = xValue;
-        } else if (xValue + localWidth > right) {
-            cx = xValue - localWidth;
+        if (localX < getContentsX()) {
+            cx = localX;
+        } else if (localX + localWidth > right) {
+            cx = localX - localWidth;
         }
-        if (yValue < getContentsY()) {
-            cy = yValue;
-        } else if (yValue + localHeight > bottom) {
-            cy = yValue - localHeight;
+        if (localY < getContentsY()) {
+            cy = localY;
+        } else if (localY + localHeight > bottom) {
+            cy = localY - localHeight;
         }
 
         if (localWidth > getVisibleWidth()) {
@@ -1107,25 +1129,25 @@ public class ScrollView extends Composite {
             align_v = true;
         }
         // compute alignment on visible area horizontally
-        if (align_h || (forceAlign && xValue + localWidth > right)) {
+        if (align_h || (forceAlign && localX + localWidth > right)) {
             // use align flags
             if ((align & SWT.LEFT) != 0) {
-                cx = xValue;
+                cx = localX;
             } else if ((align & SWT.RIGHT) != 0) {
                 cx = right - localWidth;
             } else { // center
-                cx = xValue + (localWidth - getVisibleWidth()) / 2;
+                cx = localX + (localWidth - getVisibleWidth()) / 2;
             }
         }
         // compute alignment on visible area vertically
-        if (align_v || (forceAlign && yValue + localHeight > bottom)) {
+        if (align_v || (forceAlign && localY + localHeight > bottom)) {
             // use align flags
             if ((align & SWT.TOP) != 0) {
-                cy = yValue;
+                cy = localY;
             } else if ((align & SWT.BOTTOM) != 0) {
                 cy = bottom - localHeight;
             } else { // center
-                cy = yValue + (localHeight - getVisibleHeight()) / 2;
+                cy = localY + (localHeight - getVisibleHeight()) / 2;
             }
         }
         setContentsPos(cx, cy);
@@ -1133,7 +1155,7 @@ public class ScrollView extends Composite {
 
     /**
      * Returns true if point is visible (expressed in contents coordinates).
-     * 
+     *
      * @param px Point's x position
      * @param py Point's y position
      * @return true if point is visible (expressed in contents coordinates)
@@ -1156,7 +1178,7 @@ public class ScrollView extends Composite {
 
     /**
      * Returns true if rectangle if partially visible.
-     * 
+     *
      * @param xValue x contents coordinates of rectangle.
      * @param yValue y contents coordinates of rectangle.
      * @param width width of rectangle.
@@ -1182,20 +1204,24 @@ public class ScrollView extends Composite {
     }
 
     /**
-     * Returns visible part of rectangle, or null if rectangle is not visible. Rectangle is expressed in contents
-     *         coordinates.
+     * Returns visible part of rectangle, or null if rectangle is not visible.
+     * Rectangle is expressed in contents coordinates.
      *
-     * @param xValue x contents coordinates of rectangle.
-     * @param yValue y contents coordinates of rectangle.
-     * @param width width of rectangle.
-     * @param height height of rectangle.
-     * @return visible part of rectangle, or null if rectangle is not visible. 
-     */
-    public Rectangle getVisiblePart(int xValue, int yYalue, int width, int height) {
+     * @param xValue
+     *            x contents coordinates of rectangle.
+     * @param yValue
+     *            y contents coordinates of rectangle.
+     * @param width
+     *            width of rectangle.
+     * @param height
+     *            height of rectangle.
+     * @return visible part of rectangle, or null if rectangle is not visible.
+     */
+    public Rectangle getVisiblePart(int xValue, int yValue, int width, int height) {
         if (xValue + width < getContentsX()) {
             return null;
         }
-        if (yYalue + height < getContentsY()) {
+        if (yValue + height < getContentsY()) {
             return null;
         }
         int vr = getContentsX() + getVisibleWidth();
@@ -1203,19 +1229,19 @@ public class ScrollView extends Composite {
         if (xValue > vr) {
             return null;
         }
-        if (yYalue > vb) {
+        if (yValue > vb) {
             return null;
         }
-        int rr = xValue + width, rb = yYalue + height;
-        int nl = Math.max(xValue, getContentsX()), nt = Math.max(yYalue, getContentsY()), nr = Math.min(rr, vr), nb = Math.min(rb, vb);
+        int rr = xValue + width, rb = yValue + height;
+        int nl = Math.max(xValue, getContentsX()), nt = Math.max(yValue, getContentsY()), nr = Math.min(rr, vr), nb = Math.min(rb, vb);
         return new Rectangle(nl, nt, nr - nl, nb - nt);
     }
 
     /**
-     * Returns the visible part for given rectangle. 
-     * 
+     * Returns the visible part for given rectangle.
+     *
      * @param rect A rectangle
-     * 
+     *
      * @return gets visible part of rectangle (or <code>null</code>)
      */
     public final Rectangle getVisiblePart(Rectangle rect) {
@@ -1227,7 +1253,7 @@ public class ScrollView extends Composite {
 
     /**
      * Change top left position of visible area. Check if the given point is inside contents area.
-     * 
+     *
      * @param xValue x contents coordinates of visible area.
      * @param yValue y contents coordinates of visible area.
      * @return true if view really moves
@@ -1264,21 +1290,11 @@ public class ScrollView extends Composite {
         return true;
     }
 
-    // redefined to return our vertical bar
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Scrollable#getVerticalBar()
-     */
     @Override
     public ScrollBar getVerticalBar() {
         return fVertScrollBar.getVerticalBar();
     }
 
-    // redefined to return out horizontal bar
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Scrollable#getHorizontalBar()
-     */
     @Override
     public ScrollBar getHorizontalBar() {
         return fHorScrollBar.getHorizontalBar();
@@ -1291,10 +1307,10 @@ public class ScrollView extends Composite {
      * @param forHeight height of foreground
      * @param currHorVis The current visibility state of horizontal scroll bar
      * @param currVertvis The current visibility state of vertical scroll bar
-     * @return <code>true</code> if visibility changed else <code>false</code> 
+     * @return <code>true</code> if visibility changed else <code>false</code>
      */
     public int computeBarVisibility(int forWidth, int forHeight, boolean currHorVis, boolean currVertvis) {
-        
+
         int localForWidth = forWidth;
         int vis = 0x00;
         switch (fVertScrollbarMode) {
@@ -1312,6 +1328,8 @@ public class ScrollView extends Composite {
                 }
             }
             break;
+        default:
+            break;
         }
 
         switch (fHorScrollbarMode) {
@@ -1329,12 +1347,16 @@ public class ScrollView extends Composite {
                 }
             }
             break;
+        default:
+            break;
         }
         return vis;
     }
 
     /**
-     * setup scroll bars visibility, return true if one of visibility changed.
+     * Setup scroll bars visibility.
+     *
+     * @return True if one of visibility changed.
      */
     protected boolean updateScrollBarVisiblity() {
         boolean change = false;
@@ -1344,7 +1366,6 @@ public class ScrollView extends Composite {
         int barNewVis = computeBarVisibility(getVisibleWidth(), getVisibleHeight(), currHorVis, currVertVis);
         boolean newVertVis = (barNewVis & VBAR) != 0;
         boolean newHorVis = (barNewVis & HBAR) != 0;
-        // System.out.println("SV--updateScrollBarVis old, h:"+curr_h_vis+" v:"+curr_v_vis+" new="+bar_new_vis);
         if (currVertVis ^ newVertVis) { // vertsb_.getVisible() )
             fVertScrollBar.setVisible(newVertVis);
             change = true;
@@ -1369,7 +1390,6 @@ public class ScrollView extends Composite {
      * Setup scroll bar using contents, visible and scroll bar mode properties.
      */
     protected void updateScrollBarsValues() {
-        // System.out.println("UPDATE-SCROLL-BAR-VALUES");
         /* update vertical scrollbar */
         ScrollBar b = getVerticalBar();
         if (b != null) {
@@ -1419,7 +1439,7 @@ public class ScrollView extends Composite {
      * corner control. This control is visible only if at least one scrollbar is visible. Given control will be disposed
      * by ScrollView, at dispose() time, at next setCornetControl() call or when calling setOverviewEnabled(). Pay
      * attention calling this reset overview feature until setOverviewEnabled(true) if called.
-     * @param control The control for the overview 
+     * @param control The control for the overview
      */
     public void setCornerControl(Control control) {
         if (fCornerControl != null) {
@@ -1436,7 +1456,7 @@ public class ScrollView extends Composite {
 
     /**
      * Transform (x,y) point in widget coordinates to contents coordinates.
-     * 
+     *
      * @param x The x widget coordinate.
      * @param y The y widget coordinate.
      * @return org.eclipse.swt.graphics.Point with content coordinates.
@@ -1445,21 +1465,21 @@ public class ScrollView extends Composite {
         return new Point(viewToContentsX(x), viewToContentsY(y));
     }
 
-    /** 
+    /**
      * Transform x in widget coordinates to contents coordinates
-     * 
+     *
      * @param x The y widget coordinate.
-     * @return the x content coordinate. 
+     * @return the x content coordinate.
      */
     public int viewToContentsX(int x) {
         return fContentsX + x;
     }
 
-    /** 
+    /**
      * Transform y in widget coordinates to contents coordinates
-     *  
+     *
      * @param y The y widget coordinate.
-     * @return the y content coordinate. 
+     * @return the y content coordinate.
      */
     public int viewToContentsY(int y) {
         return fContentsY + y;
@@ -1467,7 +1487,7 @@ public class ScrollView extends Composite {
 
     /**
      * Transform (x,y) point from contents coordinates, to widget coordinates.
-     * 
+     *
      * @param x The x content coordinate.
      * @param y The y content coordinate.
      * @return coordinates widget area as.
@@ -1478,7 +1498,7 @@ public class ScrollView extends Composite {
 
     /**
      * Transform X axis coordinates from contents to widgets.
-     * 
+     *
      * @param x contents coordinate to transform.
      * @return x coordinate in widget area
      */
@@ -1488,7 +1508,7 @@ public class ScrollView extends Composite {
 
     /**
      * Transform Y axis coordinates from contents to widgets.
-     * 
+     *
      * @param y contents coordinate to transform
      * @return y coordinate in widget area
      */
@@ -1498,26 +1518,28 @@ public class ScrollView extends Composite {
 
     /**
      * Return the visible height of scroll view, might be > contentsHeight
-     * 
+     *
      * @return the visible height of scroll view, might be > contentsHeight()
      */
     public int getVisibleHeight() {
-        Rectangle r = fViewControl.getClientArea();
-        return r.height;
+        return fViewControl.getClientArea().height;
     }
 
     /**
      * Return int the visible width of scroll view, might be > contentsWidth().
-     * 
+     *
      * @return int the visible width of scroll view, might be > contentsWidth()
      */
     public int getVisibleWidth() {
-        Rectangle r = fViewControl.getClientArea();
-        return r.width;
+        return fViewControl.getClientArea().width;
     }
 
     /**
-     * Add support for arrow key, scroll the ... scroll view. But you can redefine this method for your convenience.
+     * Add support for arrow key, scroll the ... scroll view. But you can
+     * redefine this method for your convenience.
+     *
+     * @param event
+     *            Keyboard event
      */
     protected void keyPressedEvent(KeyEvent event) {
         switch (event.keyCode) {
@@ -1533,34 +1555,23 @@ public class ScrollView extends Composite {
         case SWT.ARROW_RIGHT:
             scrollBy(+getVisibleWidth(), 0);
             break;
+        default:
+            break;
         }
     }
 
-    /** 
+    /**
      * Redefine this method at your convenience
+     *
      * @param event The key event.
      */
     protected void keyReleasedEvent(KeyEvent event) {
     }
 
-    /**
-     * Called when ScrollView view is resized.
-     */
-    protected void viewResized() {
-        // System.out.println("SV--viewResizeEvent()");
-        // scroll contents x,y if visible area bigger than contents...
-        if (!setContentsPos(getContentsX(), getContentsY())) {
-            // if no scroll done, scroll bar must be updated.
-            /*
-             * if( ocx==getContentsX() && ocy==getContentsY() ) { updateScrollBars(); }
-             */
-        }
-    }
-
     /**
      * Returns vertical bar width, even if bar isn't visible.
-     * 
-     * @return vertical bar width, even if bar isn't visible 
+     *
+     * @return vertical bar width, even if bar isn't visible
      */
     public int getVerticalBarWidth() {
         // include vertical bar width and trimming of scrollable used
@@ -1570,8 +1581,8 @@ public class ScrollView extends Composite {
 
     /**
      * Returns horizontal bar height even if bar isn't visible.
-     * 
-     * @return horizontal bar height even if bar isn't visible 
+     *
+     * @return horizontal bar height even if bar isn't visible
      */
     public int getHorizontalBarHeight() {
         // include horiz. bar height and trimming of scrollable used
@@ -1580,10 +1591,6 @@ public class ScrollView extends Composite {
         return bh + 1;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.swt.widgets.Scrollable#computeTrim(int, int, int, int)
-     */
     @Override
     public Rectangle computeTrim(int x, int y, int w, int h) {
         Rectangle r = new Rectangle(x, y, w, h);
@@ -1598,7 +1605,7 @@ public class ScrollView extends Composite {
     }
 
     /**
-     *  Internal layout for ScrollView, handle scrollbars, drawzone and corner control 
+     *  Internal layout for ScrollView, handle scrollbars, drawzone and corner control
      */
     protected class SVLayout extends Layout {
         /**
@@ -1609,11 +1616,7 @@ public class ScrollView extends Composite {
          * The do-it-not flag
          */
         boolean dontLayout = false;
-        
-        /*
-         * (non-Javadoc)
-         * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean)
-         */
+
         @Override
         protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
             Point p = new Point(250, 250);
@@ -1626,10 +1629,6 @@ public class ScrollView extends Composite {
             return p;
         }
 
-        /*
-         * (non-Javadoc)
-         * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
-         */
         @Override
         protected void layout(Composite composite, boolean flushCache) {
             if (dontLayout) {
@@ -1640,7 +1639,6 @@ public class ScrollView extends Composite {
                 dontLayout = true;
             }
 
-            // System.out.println(">>> SV.layout() {");
             Point cs = composite.getSize();
             int bar_vis = computeBarVisibility(cs.x, cs.y, false, false);
             boolean vb_vis = (bar_vis & VBAR) != 0;
@@ -1652,16 +1650,17 @@ public class ScrollView extends Composite {
             int wb = vb_vis ? vbw : 0;
             int hb = hb_vis ? hbh : 0;
             int cww = 0, cwh = 0;
-            // System.out.println("SV-LAYOUT H.vis="+hb_vis+" V.vis="+vb_vis);
 
             if (fCornerControl != null && (vb_vis || hb_vis)) { // corner_control_.getVisible())
                 fCornerControl.setVisible(true);
                 cww = vbw;
                 cwh = hbh;
-                if (wb == 0)
+                if (wb == 0) {
                     wb = vbw;
-                if (hb == 0)
+                }
+                if (hb == 0) {
                     hb = hbh;
+                }
             } else if (vb_vis && hb_vis) {
                 if (fCornerControl != null) {
                     fCornerControl.setVisible(false);
@@ -1677,23 +1676,9 @@ public class ScrollView extends Composite {
             int vh = cs.y - (hb_vis ? hbh : 0);
             int vbx = cs.x - wb;
             int hby = cs.y - hb;
-            Rectangle rc = fViewControl.getClientArea();
-            int old_width = rc.width;
-            int old_height = rc.height;
-            // provoque pas un viewResize ???
+
             fViewControl.setBounds(0, 0, vw, vh);
-            boolean do_view_resize = false;
-            rc = fViewControl.getClientArea();
-            if (old_width != rc.width || old_height != rc.height) {
-                // area size change, so visibleWidth()/Height() change too
-                // so scrollbars visibility ma change too..
-                // so need an other layout !
-                /*
-                 * if( updateScrollBarVisiblity() ) { layout( composite, flushCache);
-                 * System.out.println("<<< SV.layout() } (recursive)"); return ; }
-                 */
-                do_view_resize = true;
-            }
+
             if (vb_vis) {
                 fVertScrollBar.setBounds(vbx, 0, wb, cs.y - cwh);
             }
@@ -1704,11 +1689,7 @@ public class ScrollView extends Composite {
                 fCornerControl.setBounds(vbx, hby, vbw, hbh);
             }
             updateScrollBarsValues();
-            if (do_view_resize) {
-                // System.out.println(" -layout do_view_resize old="+old_width+"x"+old_height+" new="+viewcontrol_.getClientArea());
-                viewResized();
-            }
-            // System.out.println("<<< SV.layout() }");
+
             seek--;
             if (seek == 0) {
                 dontLayout = false;
@@ -1717,11 +1698,11 @@ public class ScrollView extends Composite {
     }
 
     // static must take place here... cursor is created once.
-    static Cursor fOverviewCursor;
+    volatile static Cursor fOverviewCursor;
 
     /** Support for click-and-see overview shell on this ScrollView */
     protected class Overview {
-        
+
         /**
          *  factor for X from real and overview sizes, for mouse move speed.
          */
@@ -1745,7 +1726,10 @@ public class ScrollView extends Composite {
         protected int fSaveCursorY;
 
         /**
-         *  apply overview support on a control. Replace existing corner_widget 
+         * Apply overview support on a control. Replace existing corner_widget
+         *
+         * @param control
+         *            The control to use
          */
         public void useControl(Control control) {
             final Point pos = control.getLocation();
@@ -1773,8 +1757,9 @@ public class ScrollView extends Composite {
 
                 @Override
                 public void focusLost(FocusEvent e) {
-                    if (overviewing())
+                    if (overviewing()) {
                         overviewDisappear(false);
+                    }
                 }
 
             });
@@ -1823,8 +1808,8 @@ public class ScrollView extends Composite {
             });
         }
 
-        /** 
-         * Dispose controls of overview 
+        /**
+         * Dispose controls of overview
          */
         public void dispose() {
             if (fOverview != null) {
@@ -1832,15 +1817,20 @@ public class ScrollView extends Composite {
             }
         }
 
-        /** 
+        /**
          * @return true if overview is currently on screen
          */
         protected boolean overviewing() {
             return (fOverview != null && fOverview.isVisible());
         }
 
-        /** 
+        /**
          * Process overview appear
+         *
+         * @param mx
+         *            X coordinate
+         * @param my
+         *            Y coordinate
          */
         protected void overviewAppear(int mx, int my) {
             if (fOverview == null) {
@@ -1911,8 +1901,9 @@ public class ScrollView extends Composite {
                 int s = 1;
                 byte src[] = new byte[s * s];
                 byte msk[] = new byte[s * s];
-                for (int i = 0; i < s * s; ++i)
+                for (int i = 0; i < s * s; ++i) {
                     src[i] = (byte) 0xFF;
+                }
                 ImageData i_src = new ImageData(s, s, 1, palette, 1, src);
                 ImageData i_msk = new ImageData(s, s, 1, palette, 1, msk);
                 fOverviewCursor = new Cursor(null, i_src, i_msk, 0, 0);
@@ -1929,25 +1920,23 @@ public class ScrollView extends Composite {
 
             // cx,cy to display's global coordinates
             p = toGlobalCoordinates(fOverview.getParent(), cx, cy);
-            cx = p.x;
-            cy = p.y;
-
         }
 
-        /** 
-         * Process disappear of overview 
+        /**
+         * Process disappear of overview
          */
         protected void overviewDisappear() {
             overviewDisappear(true);
         }
 
-        /** 
+        /**
          * Process disappear of overview
-         * @param restoreCursorLoc A flag to restore cursor location 
+         * @param restoreCursorLoc A flag to restore cursor location
          */
         protected void overviewDisappear(boolean restoreCursorLoc) {
-            if (fOverview == null)
+            if (fOverview == null) {
                 return;
+            }
             fOverview.setVisible(false);
             fCornerControl.setCursor(null);
             if (restoreCursorLoc) {
@@ -1968,9 +1957,9 @@ public class ScrollView extends Composite {
             overviewMove(dx, dy, event);
         }
 
-        /** 
+        /**
          * Process mouse move event when overviewing
-         *  
+         *
          * @param dx The x coordinates delta
          * @param dy The y coordinates delta
          * @param event The typed event
@@ -2018,11 +2007,14 @@ public class ScrollView extends Composite {
 
         /**
          * Convert overview coordinates to global coordinates.
-         * 
-         * @param loc the control reference
-         * @param x The x coordinate to convert
-         * @param y The y coordinate to convert
-         * @return
+         *
+         * @param loc
+         *            the control reference
+         * @param x
+         *            The x coordinate to convert
+         * @param y
+         *            The y coordinate to convert
+         * @return The new converted Point
          */
         protected Point toGlobalCoordinates(Control loc, int x, int y) {
             Point p = new Point(x, y);
This page took 0.041307 seconds and 5 git commands to generate.