Author: jerome
Date: 2009-02-12 11:29:06 +0100 (Thu, 12 Feb 2009)
New Revision: 3620
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/UI/MyScrollBarUI.java
Log:
* Added comments for packages "UI".
* Updated Typo.
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/UI/MyScrollBarUI.java
===================================================================
---
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/UI/MyScrollBarUI.java
2009-02-12 10:22:51 UTC (rev 3619)
+++
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/UI/MyScrollBarUI.java
2009-02-12 10:29:06 UTC (rev 3620)
@@ -26,11 +26,8 @@
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import javax.swing.ImageIcon;
@@ -40,45 +37,61 @@
import javax.swing.plaf.basic.BasicScrollBarUI;
import com.tuxdroid.cc.CcCommons;
+
/***
- *
* This class create a new customized ScrollBar UI.
- *
*/
public class MyScrollBarUI extends BasicScrollBarUI implements ImageObserver{
// this draws scroll
- private int bar_type = -1;
-
- public MyScrollBarUI(int type){
+ private int bar_type = MyScrollBarUI.VERTICAL;
+
+ /**
+ * Create a scrollbar UI with a custimized image.
+ * @param type VERTICAL or HORIZONTAL.
+ */
+ public MyScrollBarUI(int type)
+ {
super();
bar_type = type; //Vertical or horizontal scrollBar.
}
-
- protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
{
+
+
+ /**
+ * Paint the scroolbar with specified image.
+ */
+ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
+ {
//Override of paintThumb BasicScrollBarUI procedure.
java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
//Create ScrollBar UI.
- if (bar_type != -1){
+ if (bar_type != -1)
+ {
Image image = null;
- if (bar_type == MyScrollBarUI.VERTICAL){
+ if (bar_type == MyScrollBarUI.VERTICAL)
+ {
image =
toolkit.getImage(CcCommons.targetClass.getResource("images/scrollbar/scroll-vertic.png"));
}
- else if (bar_type == MyScrollBarUI.HORIZONTAL){
+ else if (bar_type == MyScrollBarUI.HORIZONTAL)
+ {
image =
toolkit.getImage(CcCommons.targetClass.getResource("images/scrollbar/scroll-horiz.png"));
}
//Resize image there using "Utils" class.
- if (image != null){
+ if (image != null)
+ {
Image img = com.tuxdroid.cc.Utils.image.ImgResize
(image, (int)thumbBounds.getWidth(),
(int)thumbBounds.getHeight()-1);
g.drawImage(img, (int)thumbBounds.getX(),
(int)thumbBounds.getY(), this);
}
- else{
+ else
+ {
JOptionPane.showMessageDialog(c, "Error loading ScrollBars
UI");
}
- c.addMouseListener(new java.awt.event.MouseAdapter(){
- public void mouseEntered(java.awt.event.MouseEvent event){
+ c.addMouseListener(new java.awt.event.MouseAdapter()
+ {
+ public void mouseEntered(java.awt.event.MouseEvent event)
+ {
((JComponent)event.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
});
@@ -87,23 +100,33 @@
}
}
+
- // this draws scroller background
- protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
{
+ /**
+ * Draws scroller background.
+ */
+ protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
+ {
g.setColor(new Color(142,142,142));
g.fillRect((int)trackBounds.getX(),(int)trackBounds.getY(),
(int)trackBounds.getWidth(),(int)trackBounds.getHeight());
}
+
- // and methods creating scrollbar buttons
- protected JButton createDecreaseButton(int orientation) {
+ /**
+ * This method create the 'decrease' button.
+ */
+ protected JButton createDecreaseButton(int orientation)
+ {
JButton button = new JButton();
- if (bar_type == MyScrollBarUI.VERTICAL){
+ if (bar_type == MyScrollBarUI.VERTICAL)
+ {
button.setIcon(new
ImageIcon(CcCommons.targetClass.getResource("images/scrollbar/scroll-up.png")));
}
- else if (bar_type == MyScrollBarUI.HORIZONTAL){
+ else if (bar_type == MyScrollBarUI.HORIZONTAL)
+ {
button.setIcon(new
ImageIcon(CcCommons.targetClass.getResource("images/scrollbar/scroll-left.png")));
}
button.setSize(16,16);
@@ -112,13 +135,20 @@
button.setBorderPainted(false);
return button;
}
-
- protected JButton createIncreaseButton(int orientation) {
+
+
+ /**
+ * This method create the 'increase' button.
+ */
+ protected JButton createIncreaseButton(int orientation)
+ {
JButton button = new JButton();
- if (bar_type == MyScrollBarUI.VERTICAL){
+ if (bar_type == MyScrollBarUI.VERTICAL)
+ {
button.setIcon(new
ImageIcon(CcCommons.targetClass.getResource("images/scrollbar/scroll-down.png")));
}
- else if (bar_type == MyScrollBarUI.HORIZONTAL){
+ else if (bar_type == MyScrollBarUI.HORIZONTAL)
+ {
button.setIcon(new
ImageIcon(CcCommons.targetClass.getResource("images/scrollbar/scroll-right.png")));
}
button.setSize(16,16);
@@ -129,25 +159,11 @@
button.setBorderPainted(false);
//button.setContentAreaFilled(false);
return button;
- }
+ }
+
-
- public static Image ImgResize(Image source, int width, int height) {
- /* On cr�e une nouvelle image aux bonnes dimensions. */
- BufferedImage buf = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
-
- /* On dessine sur le Graphics de l'image bufferis�e. */
- Graphics2D g = buf.createGraphics();
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(source, 0, 0, width, height, null);
- g.dispose();
- /* On retourne l'image bufferis�e, qui est une image. */
- return buf;
- }
-
- public boolean imageUpdate(Image img, int infoflags, int x, int y, int
width, int height) {
- return false;
+ public boolean imageUpdate(Image img, int infoflags, int x, int y, int
width, int height)
+ {
+ return true;
}
-
}
-
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn