/Users/lyon/j4p/src/sound/filterDesign/MyMouseBean.java

1    package sound.filterDesign; 
2     
3    // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov. 
4    // Jad home page: http://www.geocities.com/kpdus/jad.html 
5    // Decompiler options: packimports(3)  
6    // Source File Name:   MyMouseBean.java 
7     
8    import java.awt.*; 
9    import java.awt.event.MouseEvent; 
10   import java.awt.event.MouseListener; 
11   import java.beans.PropertyChangeListener; 
12   import java.beans.PropertyChangeSupport; 
13   import java.io.Serializable; 
14   import java.util.Vector; 
15    
16   public class MyMouseBean extends Canvas 
17           implements Serializable, MouseListener, MyMouseListener { 
18    
19       public MyMouseBean() { 
20           title = ""; 
21           myMouseListeners = new Vector(); 
22           pcs = new PropertyChangeSupport(this); 
23           X = Y = 0.0D; 
24           format = 1; 
25           setBackground(Color.white); 
26           setForeground(Color.black); 
27           setFont(new Font("Dialog", 0, 12)); 
28           setCursor(new Cursor(1)); 
29           addMouseListener(this); 
30       } 
31    
32       public synchronized void paint(Graphics g) { 
33           update(g); 
34       } 
35    
36       public synchronized void update(Graphics g) { 
37           Dimension dimension = getSize(); 
38           if (offGraphics == null || 
39                   dimension.width != offDimension.width || 
40                   dimension.height != offDimension.height) { 
41               offDimension = dimension; 
42               offImage = createImage(dimension.width, dimension.height); 
43               offGraphics = offImage.getGraphics(); 
44           } 
45           offGraphics.setColor(getBackground()); 
46           offGraphics.fillRect(0, 
47                   0, 
48                   offDimension.width, 
49                   offDimension.height); 
50           width = getSize().width; 
51           height = getSize().height; 
52           offGraphics.setColor(Color.black); 
53           FontMetrics fontmetrics = g.getFontMetrics(); 
54           int i = fontmetrics.getMaxAscent() - fontmetrics.getMaxDescent(); 
55           offGraphics.drawString(title, 
56                   (width - fontmetrics.stringWidth(title)) / 2, 
57                   i + 2); 
58           offGraphics.drawLine(0, i + 4, width, i + 4); 
59           offGraphics.drawString("X = " + convert(X), 3, i * 2 + 10); 
60           offGraphics.drawString("Y = " + convert(Y), 3, i * 3 + 15); 
61           offGraphics.drawRect(0, 0, width - 1, height - 1); 
62           g.drawImage(offImage, 0, 0, this); 
63       } 
64    
65       public String convert(double d) { 
66           switch (format) { 
67               case 1: // '\001' 
68                   return String.valueOf(d); 
69    
70               case 2: // '\002' 
71                   return ""; 
72    
73               case 3: // '\003' 
74                   return ""; 
75    
76               case 4: // '\004' 
77                   return ""; 
78    
79               case 5: // '\005' 
80                   return ""; 
81    
82               case 6: // '\006' 
83                   return ""; 
84    
85               case 7: // '\007' 
86                   return ""; 
87           } 
88           return ""; 
89       } 
90    
91       public void mouseOccured(MyMouseEvent mymouseevent) { 
92           setTitle(mymouseevent.getTitle()); 
93           X = mymouseevent.getX(); 
94           Y = mymouseevent.getY(); 
95           repaint(); 
96       } 
97    
98       public void mouseClicked(MouseEvent mouseevent) { 
99       } 
100   
101      public void mousePressed(MouseEvent mouseevent) { 
102      } 
103   
104      public void mouseReleased(MouseEvent mouseevent) { 
105      } 
106   
107      public void mouseEntered(MouseEvent mouseevent) { 
108      } 
109   
110      public void mouseExited(MouseEvent mouseevent) { 
111      } 
112   
113      public synchronized void addMyMouseListener( 
114              MyMouseListener mymouselistener) { 
115          myMouseListeners.addElement(mymouselistener); 
116      } 
117   
118      public synchronized void removeMyMouseListener( 
119              MyMouseListener mymouselistener) { 
120          myMouseListeners.removeElement(mymouselistener); 
121      } 
122   
123      public void addPropertyChangeListener( 
124              PropertyChangeListener propertychangelistener) { 
125          pcs.addPropertyChangeListener(propertychangelistener); 
126      } 
127   
128      public void removePropertyChangeListener( 
129              PropertyChangeListener propertychangelistener) { 
130          pcs.removePropertyChangeListener(propertychangelistener); 
131      } 
132   
133      public void setFontSize(int i) { 
134          Font font = getFont(); 
135          setFont(new Font(font.getName(), font.getStyle(), i)); 
136          pcs.firePropertyChange("fontSize", 
137                  new Integer(font.getSize()), 
138                  new Integer(i)); 
139      } 
140   
141      public void setFont(Font font) { 
142          Font font1 = getFont(); 
143          super.setFont(font); 
144          pcs.firePropertyChange("font", font1, font); 
145      } 
146   
147      public void setBackground(Color color) { 
148          Color color1 = getBackground(); 
149          super.setBackground(color); 
150          pcs.firePropertyChange("background", color1, color); 
151      } 
152   
153      public void setForeground(Color color) { 
154          Color color1 = getForeground(); 
155          super.setForeground(color); 
156          pcs.firePropertyChange("foreground", color1, color); 
157      } 
158   
159      public String getTitle() { 
160          return title; 
161      } 
162   
163      public void setTitle(String s) { 
164          title = s; 
165      } 
166   
167      public Dimension getMinimumSize() { 
168          return new Dimension(20, 20); 
169      } 
170   
171      private String title; 
172      private double X; 
173      private double Y; 
174      int format; 
175      int height; 
176      int width; 
177      private Dimension offDimension; 
178      private transient Image offImage; 
179      private transient Graphics offGraphics; 
180      private Vector myMouseListeners; 
181      private PropertyChangeSupport pcs; 
182  } 
183