summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WidgetButton.java
blob: d51fca3d8468bf3147e10f1c29c95f083d12212f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import NET.worlds.console.Console;
/*     */ import NET.worlds.console.GammaFrame;
/*     */ import NET.worlds.console.ImageCanvas;
/*     */ import java.awt.Canvas;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ abstract class WidgetButton
/*     */   extends Canvas
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */   private String name;
/*     */   private Image image;
/*     */   private Dimension dim;
/*     */   private String prompt;
/*     */   private ToolBar toolbar;
/*     */   private boolean depressed;
/*     */   
/*     */   WidgetButton(ToolBar toolbar, String name, String prompt)
/*     */   {
/*  40 */     this.name = name;
/*  41 */     this.toolbar = toolbar;
/*  42 */     this.prompt = prompt;
/*     */   }
/*     */   
/*     */   public WObject getWObject()
/*     */   {
/*  47 */     return this.toolbar.getCurrentWObject();
/*     */   }
/*     */   
/*     */   public String drag(boolean initialDrag, float deltax, float deltay)
/*     */   {
/*  52 */     return null;
/*     */   }
/*     */   
/*     */   protected ToolBar getToolBar()
/*     */   {
/*  57 */     return this.toolbar;
/*     */   }
/*     */   
/*     */   protected Point3Temp getWorldAxis(int ax, int ay, int az)
/*     */   {
/*  62 */     Point3Temp p = new Point3(ax, ay, az)
/*  63 */       .vectorTimes(Pilot.getActive());
/*  64 */     float x = Math.abs(p.x);
/*  65 */     float y = Math.abs(p.y);
/*  66 */     float z = Math.abs(p.z);
/*  67 */     if (x > y) {
/*  68 */       if (x > z) {
/*  69 */         return p.x > 0.0F ? Point3Temp.make(1.0F, 0.0F, 0.0F) : 
/*  70 */           Point3Temp.make(-1.0F, 0.0F, 0.0F);
/*     */       }
/*  72 */     } else if (y > z)
/*  73 */       return p.y > 0.0F ? Point3Temp.make(0.0F, 1.0F, 0.0F) : 
/*  74 */         Point3Temp.make(0.0F, -1.0F, 0.0F);
/*  75 */     return p.z > 0.0F ? Point3Temp.make(0.0F, 0.0F, 1.0F) : 
/*  76 */       Point3Temp.make(0.0F, 0.0F, -1.0F);
/*     */   }
/*     */   
/*     */   protected void applyWorldTransform(boolean initialDrag, Transform t)
/*     */   {
/*  81 */     WObject wobj = getWObject();
/*  82 */     if (initialDrag)
/*  83 */       Console.getFrame().getEditTile().addUndoable(
/*  84 */         new UndoablTransform(wobj));
/*  85 */     Point3Temp pos = wobj.getPosition();
/*  86 */     wobj.moveTo(0.0F, 0.0F, 0.0F).post(t).moveBy(pos);
/*  87 */     wobj.markEdited();
/*     */   }
/*     */   
/*     */   public void draw(boolean depressed)
/*     */   {
/*  92 */     this.depressed = depressed;
/*  93 */     Graphics g = getGraphics();
/*  94 */     drawOutline(g);
/*  95 */     g.dispose();
/*     */   }
/*     */   
/*     */ 
/*     */   public void perform() {}
/*     */   
/*     */ 
/*     */   public boolean usesDrag()
/*     */   {
/* 104 */     return true;
/*     */   }
/*     */   
/*     */   private void drawOutline(Graphics g)
/*     */   {
/* 109 */     g.setColor(getBackground());
/* 110 */     g.draw3DRect(0, 0, this.dim.width - 1, this.dim.height - 1, !this.depressed);
/*     */   }
/*     */   
/*     */   public boolean available()
/*     */   {
/* 115 */     return getWObject() != null;
/*     */   }
/*     */   
/*     */   public void paint(Graphics g)
/*     */   {
/* 120 */     super.paint(g);
/* 121 */     if ((available()) && (this.dim.width != 0)) {
/* 122 */       g.drawImage(this.image, 2, 2, this);
/* 123 */       drawOutline(g);
/*     */     }
/*     */   }
/*     */   
/*     */   private Dimension imageSize()
/*     */   {
/* 129 */     if (this.image == null) {
/* 130 */       this.image = ImageCanvas.getSystemImage(this.name, this);
/* 131 */       if (this.image != null) {
/* 132 */         int width = this.image.getWidth(this);
/* 133 */         int height = this.image.getHeight(this);
/* 134 */         if ((width != -1) && (height != -1)) {
/* 135 */           return this.dim = new Dimension(width + 4, height + 4);
/*     */         }
/*     */       }
/* 138 */       this.dim = new Dimension(0, 0);
/*     */     }
/* 140 */     return this.dim;
/*     */   }
/*     */   
/*     */   public Dimension getPreferredSize()
/*     */   {
/* 145 */     return imageSize();
/*     */   }
/*     */   
/*     */   public Dimension getMinimumSize()
/*     */   {
/* 150 */     return imageSize();
/*     */   }
/*     */   
/*     */   public String getPrompt()
/*     */   {
/* 155 */     return this.prompt;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WidgetButton.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */