From 67503963112b3d3a225ae00ebc899a34e54b6519 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 10 Mar 2014 15:55:25 +0100 Subject: Refactoring (structure + doc) --- .../wordpress/tipsforjava/swing/StretchIcon.java | 47 +++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/com') diff --git a/src/com/wordpress/tipsforjava/swing/StretchIcon.java b/src/com/wordpress/tipsforjava/swing/StretchIcon.java index 667f1cd..d41bbfe 100644 --- a/src/com/wordpress/tipsforjava/swing/StretchIcon.java +++ b/src/com/wordpress/tipsforjava/swing/StretchIcon.java @@ -10,6 +10,7 @@ import java.awt.Image; import java.awt.Insets; import java.awt.image.ImageObserver; import java.net.URL; + import javax.swing.ImageIcon; /** @@ -44,7 +45,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(byte[]) */ - public StretchIcon(byte[] imageData) { + public StretchIcon(final byte[] imageData) { super(imageData); } @@ -62,7 +63,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(byte[]) */ - public StretchIcon(byte[] imageData, boolean proportionate) { + public StretchIcon(final byte[] imageData, final boolean proportionate) { super(imageData); this.proportionate = proportionate; } @@ -78,7 +79,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(byte[], java.lang.String) */ - public StretchIcon(byte[] imageData, String description) { + public StretchIcon(final byte[] imageData, final String description) { super(imageData, description); } @@ -99,7 +100,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(byte[], java.lang.String) */ - public StretchIcon(byte[] imageData, String description, boolean proportionate) { + public StretchIcon(final byte[] imageData, final String description, final boolean proportionate) { super(imageData, description); this.proportionate = proportionate; } @@ -112,7 +113,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.awt.Image) */ - public StretchIcon(Image image) { + public StretchIcon(final Image image) { super(image); } @@ -128,7 +129,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.awt.Image) */ - public StretchIcon(Image image, boolean proportionate) { + public StretchIcon(final Image image, final boolean proportionate) { super(image); this.proportionate = proportionate; } @@ -143,7 +144,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.awt.Image, java.lang.String) */ - public StretchIcon(Image image, String description) { + public StretchIcon(final Image image, final String description) { super(image, description); } @@ -161,7 +162,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.awt.Image, java.lang.String) */ - public StretchIcon(Image image, String description, boolean proportionate) { + public StretchIcon(final Image image, final String description, final boolean proportionate) { super(image, description); this.proportionate = proportionate; } @@ -174,7 +175,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.lang.String) */ - public StretchIcon(String filename) { + public StretchIcon(final String filename) { super(filename); } @@ -191,7 +192,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.lang.String) */ - public StretchIcon(String filename, boolean proportionate) { + public StretchIcon(final String filename, final boolean proportionate) { super(filename); this.proportionate = proportionate; } @@ -206,7 +207,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.lang.String, java.lang.String) */ - public StretchIcon(String filename, String description) { + public StretchIcon(final String filename, final String description) { super(filename, description); } @@ -225,7 +226,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.awt.Image, java.lang.String) */ - public StretchIcon(String filename, String description, boolean proportionate) { + public StretchIcon(final String filename, final String description, final boolean proportionate) { super(filename, description); this.proportionate = proportionate; } @@ -238,7 +239,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.net.URL) */ - public StretchIcon(URL location) { + public StretchIcon(final URL location) { super(location); } @@ -254,7 +255,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.net.URL) */ - public StretchIcon(URL location, boolean proportionate) { + public StretchIcon(final URL location, final boolean proportionate) { super(location); this.proportionate = proportionate; } @@ -269,7 +270,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.net.URL, java.lang.String) */ - public StretchIcon(URL location, String description) { + public StretchIcon(final URL location, final String description) { super(location, description); } @@ -287,7 +288,7 @@ public class StretchIcon extends ImageIcon { * * @see ImageIcon#ImageIcon(java.net.URL, java.lang.String) */ - public StretchIcon(URL location, String description, boolean proportionate) { + public StretchIcon(final URL location, final String description, final boolean proportionate) { super(location, description); this.proportionate = proportionate; } @@ -317,23 +318,23 @@ public class StretchIcon extends ImageIcon { * @see ImageIcon#paintIcon(java.awt.Component, java.awt.Graphics, int, int) */ @Override - public synchronized void paintIcon(Component c, Graphics g, int x, int y) { - if (getImage() == null) { + public synchronized void paintIcon(final Component c, final Graphics g, int x, int y) { + if (this.getImage() == null) { return; } - Insets insets = ((Container) c).getInsets(); + final Insets insets = ((Container) c).getInsets(); x = insets.left; y = insets.top; int w = c.getWidth() - x - insets.right; int h = c.getHeight() - y - insets.bottom; - Image image = getImage(); + final Image image = this.getImage(); - if (proportionate) { + if (this.proportionate) { int iw = image.getWidth(c); int ih = image.getHeight(c); - if (iw * h < ih * w) { + if ((iw * h) < (ih * w)) { iw = (h * iw) / ih; x += (w - iw) / 2; w = iw; @@ -344,7 +345,7 @@ public class StretchIcon extends ImageIcon { } } - ImageObserver io = getImageObserver(); + final ImageObserver io = this.getImageObserver(); g.drawImage(image, x, y, w, h, io == null ? c : io); } -- cgit v1.2.3