home *** CD-ROM | disk | FTP | other *** search
- package teveo;
-
- import java.awt.AWTEventMulticaster;
- import java.awt.Adjustable;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.AdjustmentListener;
- import java.awt.image.ImageObserver;
-
- public class CustomSlider extends Component implements Adjustable {
- private transient AdjustmentListener adjustmentListener;
- private int blockIncr;
- private int min;
- private int max;
- private int orientation;
- private int unitIncr;
- private int val;
- private int visAmount;
- private transient Image bgImage;
- private transient Image thumbImage;
- private Point minPos;
- private Point maxPos;
- private Point thumbPos;
- private boolean isDrag;
-
- public CustomSlider(Image var1, Image var2) {
- this(var1, var2, 0);
- }
-
- public CustomSlider(Image var1, Image var2, int var3) {
- this.blockIncr = 10;
- this.min = 0;
- this.max = 100;
- this.orientation = 0;
- this.unitIncr = 1;
- this.val = 0;
- this.visAmount = 0;
- this.thumbPos = new Point();
- this.bgImage = var1;
- this.thumbImage = var2;
- Dimension var4 = this.getSize();
- super.setSize(var4.width, var4.height);
- if (var3 == 1) {
- this.orientation = 1;
- this.minPos = new Point(0, 0);
- this.maxPos = new Point(var4.width - (this.thumbImage == null ? 0 : this.thumbImage.getWidth((ImageObserver)null)) - 1, 0);
- } else {
- this.orientation = 0;
- this.minPos = new Point(0, 0);
- this.maxPos = new Point(0, var4.height - (this.thumbImage == null ? 0 : this.thumbImage.getHeight((ImageObserver)null)) - 1);
- }
-
- this.setValue(0);
- ((Component)this).addMouseListener(new 1(this));
- ((Component)this).addMouseMotionListener(new 2(this));
- }
-
- // $FF: synthetic method
- static boolean access$0(CustomSlider var0) {
- return var0.isDrag;
- }
-
- // $FF: synthetic method
- static void access$1(CustomSlider var0, boolean var1) {
- var0.isDrag = var1;
- }
-
- // $FF: synthetic method
- static Point access$2(CustomSlider var0) {
- return var0.thumbPos;
- }
-
- // $FF: synthetic method
- static AdjustmentListener access$3(CustomSlider var0) {
- return var0.adjustmentListener;
- }
-
- // $FF: synthetic method
- static Image access$4(CustomSlider var0) {
- return var0.thumbImage;
- }
-
- // $FF: synthetic method
- static Point access$5(CustomSlider var0) {
- return var0.minPos;
- }
-
- // $FF: synthetic method
- static Point access$6(CustomSlider var0) {
- return var0.maxPos;
- }
-
- // $FF: synthetic method
- static int access$7(CustomSlider var0) {
- return var0.min;
- }
-
- // $FF: synthetic method
- static int access$8(CustomSlider var0) {
- return var0.max;
- }
-
- public void addAdjustmentListener(AdjustmentListener var1) {
- this.adjustmentListener = AWTEventMulticaster.add(this.adjustmentListener, var1);
- }
-
- public int getBlockIncrement() {
- return this.blockIncr;
- }
-
- public int getMaximum() {
- return this.max;
- }
-
- public int getMinimum() {
- return this.min;
- }
-
- public Dimension getMinimumSize() {
- return this.getSize();
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public Dimension getPreferredSize() {
- return this.getSize();
- }
-
- public Dimension getSize() {
- return this.bgImage == null ? super.getSize() : new Dimension(this.bgImage.getWidth((ImageObserver)null), this.bgImage.getHeight((ImageObserver)null));
- }
-
- public int getTravelRange() {
- int var1 = 0;
- if (this.orientation == 0) {
- var1 = this.maxPos.x - this.minPos.x;
- } else if (this.orientation == 1) {
- var1 = this.maxPos.y - this.minPos.y;
- }
-
- return var1;
- }
-
- public int getUnitIncrement() {
- return this.unitIncr;
- }
-
- public int getValue() {
- return this.val;
- }
-
- public int getVisibleAmount() {
- return this.visAmount;
- }
-
- protected boolean isInThumb(Point var1) {
- Rectangle var2 = new Rectangle(this.thumbPos.x, this.thumbPos.y, this.thumbImage.getWidth((ImageObserver)null), this.thumbImage.getHeight((ImageObserver)null));
- return var2.contains(var1);
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public void removeAdjustmentListener(AdjustmentListener var1) {
- this.adjustmentListener = AWTEventMulticaster.remove(this.adjustmentListener, var1);
- }
-
- public void setBlockIncrement(int var1) {
- this.blockIncr = Math.max(var1, this.getUnitIncrement());
- }
-
- public void setMaximum(int var1) {
- this.max = var1;
- }
-
- public void setMinimum(int var1) {
- this.min = var1;
- }
-
- public void setSize(int var1, int var2) {
- }
-
- public void setSize(Dimension var1) {
- this.setSize(var1.width, var1.height);
- }
-
- protected void setThumbPos(Point var1) {
- if (this.orientation == 0) {
- if (var1.x < this.minPos.x) {
- var1.x = this.minPos.x;
- } else if (var1.x > this.maxPos.x) {
- var1.x = this.maxPos.x;
- }
-
- if (var1.y != this.minPos.y) {
- var1.y = this.minPos.y;
- }
- } else if (this.orientation == 1) {
- if (var1.y < this.minPos.y) {
- var1.y = this.minPos.y;
- } else if (var1.y > this.maxPos.y) {
- var1.y = this.maxPos.y;
- }
-
- if (var1.x != this.minPos.x) {
- var1.x = this.minPos.x;
- }
- }
-
- this.thumbPos = var1;
- ((Component)this).repaint();
- }
-
- public void setTravel(Point var1, Point var2) {
- this.minPos = var1;
- this.maxPos = var2;
- }
-
- public void setUnitIncrement(int var1) {
- this.unitIncr = Math.min(var1, this.getBlockIncrement());
- }
-
- public void setValue(int var1) {
- if (var1 < this.min) {
- var1 = this.min;
- } else if (var1 > this.max) {
- var1 = this.max;
- }
-
- var1 -= var1 % this.unitIncr;
- this.val = var1;
- Point var2 = new Point();
- int var3 = this.max - this.min;
- int var4 = this.getTravelRange();
- switch (this.orientation) {
- case 0:
- var2.x = this.minPos.x + var4 * this.val / var3;
- var2.y = this.minPos.y;
- break;
- case 1:
- var2.y = this.minPos.y + var4 * this.val / var3;
- var2.x = this.minPos.x;
- break;
- default:
- return;
- }
-
- this.setThumbPos(var2);
- }
-
- public void setVisibleAmount(int var1) {
- this.visAmount = var1;
- }
-
- public void update(Graphics var1) {
- var1.drawImage(this.bgImage, 0, 0, (ImageObserver)null);
- var1.drawImage(this.thumbImage, this.thumbPos.x, this.thumbPos.y, (ImageObserver)null);
- }
- }
-