source: ether_statistics/service/implementation/gov/noaa/pmel/swing/beans/SliderHandle.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 3.0 KB
Line 
1/*
2 * $Id: SliderHandle.java,v 1.2 2000/02/09 00:21:57 dwd Exp $
3 */
4 
5package gov.noaa.pmel.swing.beans;
6 
7import java.awt.Color;
8import java.awt.Graphics;
9 
10/**
11 * Description of Class SliderHandle
12 *
13 * @author Donald Denbo
14 * @version $Revision: 1.2 $, $Date: 2000/02/09 00:21:57 $
15**/
16public class SliderHandle implements java.io.Serializable {
17  static public int LEFT = 0;
18  static public int RIGHT = 1;
19  static public int SINGLE = 2;
20  Color color_;
21  int size_;
22  int posx_;
23  int posy_;
24  int style_ = SINGLE;
25  int[] xpts = new int[9];
26  int[] ypts = new int[9];
27  /**
28   * Default constructor
29   **/
30  public SliderHandle() {
31    this(6, Color.red, SINGLE);
32  }
33  public SliderHandle(int size, Color color) {
34    this(size, color, SINGLE);
35  }
36  /**
37   * SliderHandle constructor.
38   *
39   * @param xpos horizontal position of handle
40   * @param ypos vertical position of handle
41   * @param size size of handle in pixels
42   * @param color handle color
43   **/
44  public SliderHandle(int size, Color color, int style) {
45    size_ = size;
46    color_ = color;
47    style_ = style;
48  }
49  /**
50   * Get the size of the handle in pixels;
51   *
52   * @return handle size
53   **/
54  public int getSize() {
55    return size_;
56  }
57  /**
58   * Set the size of the handle (in pixels).
59   *
60   * @param sz handle size in pixels
61   **/
62  public void setSize(int sz) {
63    size_ = sz;
64  }
65  public void setStyle(int st) {
66    style_ = st;
67  }
68  public int getStyle() {
69    return style_;
70  }
71  /**
72   * Get the color of the handle
73   *
74   * @return the handle color
75   **/
76  public Color getColor() {
77    return color_;
78  }
79  /**
80   * Set the handle color
81   *
82   * @param clr handle color
83   **/
84  public void setColor(Color clr) {
85    color_ = clr;
86  }
87  /**
88   * Get the current handle position
89   *
90   * @return current handle position
91   **/
92  public int getPosition() {
93    return posx_;
94  }
95  public void draw(Graphics g, int posx, int posy) {
96    g.setColor(color_);
97       
98    posx_ = posx;
99    posy_ = posy;
100
101    int pt = 0;
102    if(style_ == SINGLE || style_ == LEFT) {
103      xpts[0] = posx_;
104      ypts[0] = posy_;
105      xpts[1] = posx_ - size_;
106      ypts[1] = posy_ + size_;
107      xpts[2] = xpts[1];
108      ypts[2] = ypts[1] + size_;
109      xpts[3] = xpts[0];
110      ypts[3] = ypts[2];
111      xpts[4] = xpts[0];
112      ypts[4] = ypts[0];
113      pt = 5;
114    }
115    if(style_ == SINGLE || style_ == RIGHT) {
116      if(pt == 0) {
117        xpts[pt] = posx_;
118        ypts[pt] = posy_;
119        pt++;
120      } else {
121        pt = 4;
122      }
123      xpts[pt] = posx_;
124      ypts[pt] = posy_ + 2*size_;
125      xpts[pt+1] = posx_ + size_;
126      ypts[pt+1] = ypts[pt];
127      xpts[pt+2] = xpts[pt+1];
128      ypts[pt+2] = posy_ + size_;
129      xpts[pt+3] = posx_;
130      ypts[pt+3] = posy_;
131      pt = pt + 4;
132    }
133   
134 /*   xpts[0] = posx_;
135    ypts[0] = posy_;
136    xpts[1] = posx_ - size_;
137    ypts[1] = posy_ + 2*size_;
138    xpts[2] = posx_ + size_;
139    ypts[2] = ypts[1];
140    xpts[3] = xpts[0];
141    ypts[3] = ypts[0]; */
142       
143    g.fillPolygon(xpts, ypts, pt);
144  }
145}
Note: See TracBrowser for help on using the repository browser.