home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Panel;
-
- class ocsb extends Panel implements Runnable {
- public static final int SCROLL_LINE_UP = 601;
- public static final int SCROLL_LINE_DOWN = 602;
- public static final int SCROLL_PAGE_UP = 603;
- public static final int SCROLL_PAGE_DOWN = 604;
- public static final int SCROLL_ABSOLUTE = 605;
- public int sbHeight;
- public int sbWidth;
- private int sbValue;
- private int pageIncrement;
- private int sbMax;
- private int sbIncrement = 1;
- private Thread goauto;
- private boolean paint_called;
- private boolean first_run = true;
- private boolean on_top;
- private boolean on_bottom;
- private boolean m_down;
- private boolean dragging_bubble;
- private boolean bad_scroll = true;
- private boolean mouse_in;
- private boolean m_off;
- private boolean bypass;
- private Event the_e;
- private int auto_type;
- // $FF: renamed from: mx int
- private int field_0;
- // $FF: renamed from: my int
- private int field_1;
- private int drag_move;
- private float hbp;
- private Color button_color;
- private Color arrow_color;
- private Color harrow_color;
- private Color bg_color;
- private Color slider_color;
- private Color outline_color;
- private int slider_inset;
- private int last_button;
- private int auto_delay;
- private int auto_rate;
- private int bubble_range;
- private float bubble_pos;
- private float bubble_inc;
- private int position;
- private Image sboff;
- private Graphics g_sboff;
-
- public void start() {
- if (this.goauto == null) {
- this.goauto = new Thread(this);
- this.goauto.start();
- }
-
- }
-
- public void stop() {
- if (this.goauto != null) {
- this.goauto.stop();
- this.goauto = null;
- }
-
- }
-
- public void reshape(int x, int y, int width, int height) {
- if (width * height > 0) {
- this.sbWidth = width;
- this.sbHeight = height;
- this.figureBubble(true);
- super.reshape(x, y, width, height);
- }
- }
-
- public boolean mouseExit(Event e, int x, int y) {
- if (this.bad_scroll) {
- return true;
- } else {
- this.mouse_in = false;
- this.m_off = true;
- this.undoHButtons();
- return true;
- }
- }
-
- private void checkDbutton(Event e, int type) {
- if (type == 1) {
- this.sbValue += this.sbIncrement;
- if (this.sbValue > this.sbMax) {
- this.sbValue = this.sbMax;
- }
-
- this.DrawBubble(false);
- this.paintIt(((Component)this).getGraphics());
- e.id = 602;
- ((Component)this).postEvent(e);
- } else if (type == 2) {
- this.sbValue -= this.sbIncrement;
- if (this.sbValue < 0) {
- this.sbValue = 0;
- }
-
- this.DrawBubble(false);
- this.paintIt(((Component)this).getGraphics());
- e.id = 601;
- ((Component)this).postEvent(e);
- } else if (type == 3) {
- this.sbValue -= this.pageIncrement;
- if (this.sbValue < 0) {
- this.sbValue = 0;
- }
-
- this.DrawBubble(false);
- this.paintIt(((Component)this).getGraphics());
- e.id = 603;
- ((Component)this).postEvent(e);
- } else {
- if (type == 4) {
- this.sbValue += this.pageIncrement;
- if (this.sbValue > this.sbMax) {
- this.sbValue = this.sbMax;
- }
-
- this.DrawBubble(false);
- this.paintIt(((Component)this).getGraphics());
- e.id = 604;
- ((Component)this).postEvent(e);
- }
-
- }
- }
-
- public boolean mouseMove(Event event, int cx, int cy) {
- if (!this.m_down && !this.bad_scroll) {
- if (this.cButtons(cy)) {
- return true;
- } else {
- this.undoHButtons();
- return true;
- }
- } else {
- return true;
- }
- }
-
- private void undoHButtons() {
- if (this.on_bottom) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
- this.paintIt(((Component)this).getGraphics());
- this.on_bottom = false;
- }
-
- if (this.on_top) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
- this.paintIt(((Component)this).getGraphics());
- this.on_top = false;
- }
-
- }
-
- private void DrawBubble(boolean absolute) {
- if (!this.bad_scroll) {
- this.g_sboff.setColor(this.bg_color);
- this.g_sboff.fillRect(0, (int)this.bubble_pos, this.sbWidth, this.sbWidth);
- this.drawSlider();
- if (!absolute) {
- this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth;
- } else {
- this.bubble_pos = this.hbp;
- float temp = (this.bubble_pos - (float)this.sbWidth) / (float)this.bubble_range;
- this.sbValue = (int)(temp * (float)this.sbMax);
- }
-
- this.drawButton(0, (int)this.bubble_pos, this.sbWidth - 1, this.sbWidth - 1, 0, this.arrow_color);
- }
-
- }
-
- public boolean mouseDown(Event e, int x, int y) {
- this.m_down = true;
- if (this.bad_scroll) {
- return true;
- } else if (this.on_bottom) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 4, this.harrow_color);
- this.last_button = 1;
- this.auto_type = 1;
- this.checkDbutton(e, this.auto_type);
- this.the_e = e;
- this.start();
- return true;
- } else if (this.on_top) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 3, this.harrow_color);
- this.last_button = 2;
- this.auto_type = 2;
- this.checkDbutton(e, this.auto_type);
- this.the_e = e;
- this.start();
- return true;
- } else {
- if (x >= 0 && x <= this.sbWidth) {
- if ((float)y >= this.bubble_pos && (float)y < this.bubble_pos + (float)this.sbWidth) {
- this.dragging_bubble = true;
- this.drag_move = y;
- return true;
- }
-
- if ((float)y < this.bubble_pos) {
- this.field_1 = y;
- this.field_0 = x;
- this.auto_type = 3;
- this.checkDbutton(e, this.auto_type);
- this.the_e = e;
- this.start();
- } else {
- this.field_1 = y;
- this.field_0 = x;
- this.auto_type = 4;
- this.checkDbutton(e, this.auto_type);
- this.the_e = e;
- this.start();
- }
- }
-
- return true;
- }
- }
-
- public void setBarStyle(int si, Color bc, Color ac, Color hc, Color bgc, Color sc, Color oc) {
- this.button_color = bc;
- this.arrow_color = ac;
- this.harrow_color = hc;
- this.bg_color = bgc;
- this.slider_color = sc;
- this.outline_color = oc;
- this.slider_inset = si;
- }
-
- private synchronized void paintIt(Graphics g) {
- if (this.paint_called) {
- if (!this.first_run) {
- ((Component)this).setBackground(this.bg_color);
- if (this.sbWidth * this.sbHeight <= 0) {
- return;
- }
-
- this.sboff = ((Component)this).createImage(this.sbWidth, this.sbHeight);
- this.g_sboff = this.sboff.getGraphics();
- this.drawBar(g);
- this.first_run = true;
- } else {
- g.drawImage(this.sboff, 0, 0, this);
- }
-
- }
- }
-
- private void drawBar(Graphics g) {
- this.g_sboff.setColor(this.bg_color);
- this.g_sboff.fillRect(0, 0, this.sbWidth, this.sbHeight);
- this.drawSlider();
- if (!this.bad_scroll) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
- this.DrawBubble(false);
- } else {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, Color.gray);
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, Color.gray);
- }
-
- g.drawImage(this.sboff, 0, 0, this);
- }
-
- public boolean mouseEnter(Event e, int x, int y) {
- this.mouse_in = true;
- return true;
- }
-
- public void resize(Dimension d) {
- if (d.width * d.height > 0) {
- this.sbWidth = d.width;
- this.sbHeight = d.height;
- this.figureBubble(true);
- super.resize(d);
- }
- }
-
- public void resize(int width, int height) {
- if (width * height > 0) {
- this.sbWidth = width;
- this.sbHeight = height;
- this.figureBubble(true);
- super.resize(width, height);
- }
- }
-
- public int getValue() {
- return this.sbValue;
- }
-
- public boolean mouseDrag(Event event, int cx, int cy) {
- this.field_0 = cx;
- this.field_1 = cy;
- if (this.bad_scroll) {
- return true;
- } else {
- if (this.dragging_bubble) {
- if (this.drag_move != cy) {
- this.hbp = this.bubble_pos + (float)(cy - this.drag_move);
- if (this.hbp > (float)(this.bubble_range + this.sbWidth)) {
- this.hbp = (float)(this.bubble_range + this.sbWidth);
- }
-
- if (this.hbp < (float)this.sbWidth) {
- this.hbp = (float)this.sbWidth;
- }
-
- this.DrawBubble(true);
- this.paintIt(((Component)this).getGraphics());
- event.id = 605;
- ((Component)this).postEvent(event);
- this.drag_move = cy;
- }
- } else {
- if (this.auto_type > 2) {
- return true;
- }
-
- if (cx > 0 && cx < this.sbWidth && this.cButtons(cy)) {
- this.m_off = false;
- return true;
- }
-
- this.m_off = true;
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
- this.on_bottom = false;
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
- this.on_top = false;
- this.stop();
- this.auto_type = 0;
- this.paintIt(((Component)this).getGraphics());
- }
-
- return true;
- }
- }
-
- public Dimension preferredSize() {
- return new Dimension(14, 75);
- }
-
- public boolean mouseUp(Event evt, int x, int y) {
- if (this.bad_scroll) {
- return true;
- } else {
- this.m_down = false;
- this.dragging_bubble = false;
- this.last_button = 0;
- this.stop();
- this.auto_type = 0;
- if (this.m_off) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
- this.paintIt(((Component)this).getGraphics());
- this.on_bottom = false;
- this.on_top = false;
- this.m_off = false;
- return true;
- } else if (this.on_bottom) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.harrow_color);
- this.paintIt(((Component)this).getGraphics());
- return true;
- } else if (this.on_top) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.harrow_color);
- this.paintIt(((Component)this).getGraphics());
- return true;
- } else {
- return true;
- }
- }
- }
-
- ocsb() {
- this.button_color = Color.lightGray;
- this.arrow_color = Color.black;
- this.harrow_color = Color.yellow;
- this.bg_color = Color.white;
- this.slider_color = Color.black;
- this.outline_color = Color.lightGray;
- this.auto_delay = 5;
- this.auto_rate = 40;
- }
-
- ocsb(int width, int height) {
- this.button_color = Color.lightGray;
- this.arrow_color = Color.black;
- this.harrow_color = Color.yellow;
- this.bg_color = Color.white;
- this.slider_color = Color.black;
- this.outline_color = Color.lightGray;
- this.auto_delay = 5;
- this.auto_rate = 40;
- this.sbWidth = width;
- this.sbHeight = height;
- this.figureBubble(false);
- }
-
- public void run() {
- while(true) {
- if (!this.bypass) {
- try {
- Thread.sleep((long)(this.auto_delay * 100));
- } catch (InterruptedException var4) {
- }
- } else {
- this.bypass = false;
- }
-
- while(this.m_down) {
- if (this.auto_type != 3 && this.auto_type != 4 || this.field_0 > 0 && this.field_0 < this.sbWidth && this.field_1 <= this.sbHeight - this.sbWidth && this.field_1 >= this.sbWidth && (this.auto_type != 3 || !((float)this.field_1 > this.bubble_pos)) && (this.auto_type != 4 || !((float)this.field_1 < this.bubble_pos + (float)this.sbWidth))) {
- this.checkDbutton(this.the_e, this.auto_type);
-
- try {
- Thread.sleep((long)this.auto_rate);
- } catch (InterruptedException var3) {
- }
- }
- }
- }
- }
-
- private void drawSlider() {
- this.g_sboff.setColor(this.slider_color);
- this.g_sboff.fillRect(this.slider_inset, this.sbWidth, this.sbWidth - (this.slider_inset * 2 + 1), this.sbHeight - this.sbWidth * 2);
- this.g_sboff.setColor(this.outline_color);
- this.g_sboff.drawLine(this.slider_inset, this.sbWidth, this.slider_inset, this.sbHeight - (this.sbWidth + 1));
- this.g_sboff.drawLine(this.sbWidth - (this.slider_inset + 1), this.sbWidth, this.sbWidth - (this.slider_inset + 1), this.sbHeight - (this.sbWidth + 1));
- }
-
- public void setValues(int pageinc, int end) {
- this.sbMax = end;
- this.pageIncrement = pageinc;
- if (this.sbMax < 1) {
- this.bad_scroll = true;
- this.bubble_pos = (float)this.sbWidth;
- } else {
- this.bad_scroll = false;
- }
-
- this.bubble_pos = 0.0F;
- this.sbValue = 0;
- this.figureBubble(true);
- }
-
- private void drawButton(int x, int y, int width, int height, int type, Color ac) {
- this.g_sboff.setColor(this.button_color);
- if (type != 0 && type != 1 && type != 2) {
- this.g_sboff.fillRect(x + 1, y + 1, width - 1, height - 1);
- } else {
- this.g_sboff.fillRect(x + 2, y + 2, width - 2, height - 2);
- }
-
- if (type == 1 || type == 2 || type == 3 || type == 4) {
- int ystart = 0;
- int size = 6;
- int vadd = 2;
- int xstart = width / 2 - 2;
- if (width < 11) {
- size = 4;
- vadd = 1;
- xstart = width / 2 - 2;
- } else {
- xstart = width / 2 - 3;
- }
-
- if (type != 2 && type != 4) {
- ystart = height / 2 + vadd;
- } else {
- ystart = this.sbHeight - height / 2 - (vadd + 2);
- }
-
- this.g_sboff.setColor(ac);
- if (type == 3 || type == 4) {
- ++xstart;
- ++ystart;
- }
-
- for(int i = size; i >= 0; i -= 2) {
- this.g_sboff.drawLine(xstart, ystart, xstart + i, ystart);
- ++xstart;
- if (type != 2 && type != 4) {
- --ystart;
- } else {
- ++ystart;
- }
- }
- }
-
- if (type != 0 && type != 1 && type != 2) {
- this.g_sboff.setColor(Color.gray);
- this.g_sboff.drawRect(x, y, width, height);
- } else {
- this.g_sboff.setColor(Color.lightGray);
- this.g_sboff.drawRect(x + 1, y + 1, width - 1, height - 1);
- this.g_sboff.setColor(Color.gray);
- this.g_sboff.drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
- this.g_sboff.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 1);
- this.g_sboff.setColor(Color.white);
- this.g_sboff.drawRect(x, y, width, height);
- this.g_sboff.setColor(Color.black);
- this.g_sboff.drawLine(x, y + height, x + width, y + height);
- this.g_sboff.drawLine(x + width, y, x + width, y + height);
- }
-
- }
-
- public void figureBubble(boolean redo) {
- this.bubble_range = this.sbHeight - this.sbWidth * 3;
- this.bubble_inc = (float)this.bubble_range / (float)this.sbMax;
- this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth;
- if (redo) {
- this.first_run = false;
- this.paintIt(((Component)this).getGraphics());
- }
-
- }
-
- public void paint(Graphics g) {
- this.paint_called = true;
- this.paintIt(((Component)this).getGraphics());
- }
-
- public void setBubblePos(int sbval) {
- if (sbval < 1) {
- this.sbValue = 1;
- }
-
- if (sbval > this.sbMax) {
- this.sbValue = this.sbMax;
- }
-
- this.figureBubble(true);
- }
-
- private boolean cButtons(int cy) {
- if (cy < this.sbWidth && cy >= 0) {
- if (!this.on_top) {
- this.on_top = true;
- if (!this.m_down) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.harrow_color);
- } else if (this.last_button != 1) {
- this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 3, this.harrow_color);
- this.bypass = true;
- this.auto_type = 2;
- this.start();
- } else {
- this.on_top = false;
- }
-
- this.paintIt(((Component)this).getGraphics());
- }
-
- return true;
- } else if (cy > this.sbHeight - this.sbWidth && cy <= this.sbHeight) {
- if (!this.on_bottom) {
- this.on_bottom = true;
- if (!this.m_down) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.harrow_color);
- } else if (this.last_button != 2) {
- this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 4, this.harrow_color);
- this.bypass = true;
- this.auto_type = 1;
- this.start();
- } else {
- this.on_bottom = false;
- }
-
- this.paintIt(((Component)this).getGraphics());
- }
-
- return true;
- } else {
- return false;
- }
- }
- }
-