/* */ package NET.worlds.console; /* */ /* */ import java.awt.Color; /* */ import java.awt.Component; /* */ import java.awt.Dimension; /* */ import java.awt.Event; /* */ import java.awt.Graphics; /* */ import java.awt.Panel; /* */ import java.awt.Rectangle; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class FourTilePanel /* */ extends Panel /* */ { /* */ private static final long serialVersionUID = -7002173409842219262L; /* */ private static final int tw = 5; /* */ private static final int th = 5; /* */ private static final int aw = 7; /* */ private static final int ah = 4; /* */ private static final int bw = 3; /* 39 */ private static Color widgetColor = new Color(255, 238, 177); /* 40 */ private static Color lineColor = new Color(162, 162, 162); /* */ /* */ /* 43 */ private Component[] comps = new Component[4]; /* 44 */ private int[] order = { 0, 1, 2, 3 }; /* 45 */ private float[] divider = { 0.22F, 0.63F }; /* */ private int tx; /* */ private int ty; /* */ private int prevWidth; /* */ private int prevHeight; /* 50 */ private Rectangle moveWidget = new Rectangle(); /* 51 */ private FourTileSwapper swap01 = new FourTileSwapper(this, 0, 1); /* 52 */ private FourTileSwapper swap02 = new FourTileSwapper(this, 0, 2); /* 53 */ private FourTileSwapper swap23 = new FourTileSwapper(this, 2, 3); /* 54 */ private FourTileSwapper swap13 = new FourTileSwapper(this, 1, 3); /* 55 */ private FourTileSwapper[] swaps = { this.swap01, this.swap02, this.swap23, this.swap13 }; /* */ /* */ private boolean dragging; /* */ private int offsetx; /* */ private int offsety; /* */ private int minx; /* */ private int miny; /* */ private int maxx; /* */ private int maxy; /* */ private int specialTileIndex; /* */ private Component oneTile; /* */ /* */ public FourTilePanel(Component ul, Component ur, Component ll, Component lr, int special) /* */ { /* 69 */ setLayout(null); /* 70 */ this.specialTileIndex = special; /* 71 */ add(this.comps[0] = ul); /* 72 */ add(this.comps[1] = ur); /* 73 */ add(this.comps[2] = ll); /* 74 */ add(this.comps[3] = lr); /* 75 */ setBackground(Color.black); /* */ /* 77 */ if (GammaFrameState.restoreLayout(this.order, this.divider)) { /* 78 */ useOneTileMode(); /* */ } else { /* 80 */ useFourTileMode(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public boolean isOneTileMode() /* */ { /* 90 */ return this.oneTile != null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void useOneTileMode() /* */ { /* 100 */ if (this.oneTile != null) /* 101 */ return; /* 102 */ this.oneTile = this.comps[this.specialTileIndex]; /* */ /* 104 */ for (int i = 0; i < 4; i++) { /* 105 */ if (i != this.specialTileIndex) /* 106 */ remove(this.comps[i]); /* */ } /* 108 */ moveComponents(); /* 109 */ saveLayout(); /* 110 */ validate(); /* */ } /* */ /* */ /* */ /* */ public void useFourTileMode() /* */ { /* 117 */ if (this.oneTile == null) /* 118 */ return; /* 119 */ this.oneTile = null; /* */ /* 121 */ for (int i = 0; i < 4; i++) { /* 122 */ if (i != this.specialTileIndex) /* 123 */ add(this.comps[i]); /* */ } /* 125 */ moveComponents(); /* 126 */ saveLayout(); /* 127 */ validate(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void setBounds(int x, int y, int width, int height) /* */ { /* 152 */ super.setBounds(x, y, width, height); /* */ /* 154 */ if (GammaFrameState.isIconic()) { /* 155 */ return; /* */ } /* 157 */ if (this.prevWidth != width) { /* 158 */ this.tx = Math.max((int)(this.divider[0] * width), 12); /* 159 */ this.prevWidth = width; /* */ } /* */ /* 162 */ if (this.prevHeight != height) { /* 163 */ this.ty = Math.max((int)(this.divider[1] * height), 9); /* 164 */ this.prevHeight = height; /* */ } /* */ /* 167 */ moveComponents(width, height); /* */ } /* */ /* */ private void saveLayout() /* */ { /* 172 */ GammaFrameState.saveLayout(this.order, this.divider, this.oneTile != null); /* */ } /* */ /* */ private void moveComponents() { /* 176 */ Dimension size = getSize(); /* 177 */ moveComponents(size.width, size.height); /* */ } /* */ /* */ /* */ private void moveComponents(int width, int height) /* */ { /* 183 */ if (this.oneTile == null) { /* 184 */ this.comps[this.order[0]].setBounds(3, 3, this.tx - 3, this.ty - 3); /* 185 */ this.comps[this.order[1]].setBounds(this.tx + 5, 3, width - this.tx - 5 - 3, this.ty - 3); /* 186 */ this.comps[this.order[2]] /* 187 */ .setBounds(3, this.ty + 5, this.tx - 3, height - this.ty - 5 - 3); /* 188 */ this.comps[this.order[3]].setBounds(this.tx + 5, this.ty + 5, width - this.tx - 5 - 3, /* 189 */ height - this.ty - 5 - 3); /* */ } else { /* 191 */ this.oneTile.setBounds(0, 0, width, height); /* */ } /* 193 */ repaint(); /* */ } /* */ /* */ public void paint(Graphics g) /* */ { /* 198 */ Dimension size = getSize(); /* */ /* 200 */ g.setColor(getBackground()); /* */ /* */ /* 203 */ if (this.oneTile != null) { /* 204 */ return; /* */ } /* */ /* 207 */ g.fillRect(0, 0, 3, size.height); /* 208 */ g.fillRect(0, 0, size.width, 3); /* 209 */ g.fillRect(0, size.height - 3, size.width, 3); /* 210 */ g.fillRect(size.width - 3, 0, 3, size.height); /* */ /* */ /* 213 */ g.fillRect(0, this.ty, size.width, 5); /* 214 */ g.fillRect(this.tx, 0, 5, size.height); /* */ /* 216 */ g.setColor(lineColor); /* */ /* */ /* 219 */ g.drawLine(0, this.ty + 2, size.width, this.ty + 2); /* 220 */ g.drawLine(this.tx + 2, 0, this.tx + 2, size.height); /* */ /* 222 */ g.setColor(widgetColor); /* */ /* */ /* 225 */ g.fillRect(this.tx, this.ty, 5, 5); /* 226 */ this.moveWidget.setBounds(this.tx, this.ty, 5, 5); /* */ /* */ /* 229 */ int tmp = (this.tx + 2 - 7) / 2; /* 230 */ g.fillArc(tmp, this.ty - 2, 7, 4, 0, 65356); /* 231 */ g.fillArc(tmp, this.ty + 5 - 2, 7, 4, 0, 180); /* 232 */ this.swap02.setBounds(tmp, this.ty, 7, 5); /* */ /* */ /* 235 */ tmp = (this.tx + 2 + size.width - 7) / 2; /* 236 */ g.fillArc(tmp, this.ty - 2, 7, 4, 0, 65356); /* 237 */ g.fillArc(tmp, this.ty + 5 - 2, 7, 4, 0, 180); /* 238 */ this.swap13.setBounds(tmp, this.ty, 7, 5); /* */ /* */ /* 241 */ tmp = (this.ty + 2 - 7) / 2; /* 242 */ g.fillArc(this.tx - 2, tmp, 4, 7, 90, 65356); /* 243 */ g.fillArc(this.tx + 5 - 2, tmp, 4, 7, 90, 180); /* 244 */ this.swap01.setBounds(this.tx, tmp, 5, 7); /* */ /* */ /* 247 */ tmp = (this.ty + 2 + size.height - 7) / 2; /* 248 */ g.fillArc(this.tx - 2, tmp, 4, 7, 90, 65356); /* 249 */ g.fillArc(this.tx + 5 - 2, tmp, 4, 7, 90, 180); /* 250 */ this.swap23.setBounds(this.tx, tmp, 5, 7); /* */ } /* */ /* */ public boolean mouseDrag(Event evt, int x, int y) /* */ { /* 255 */ if (this.dragging) { /* 256 */ this.tx = (x + this.offsetx); /* 257 */ this.ty = (y + this.offsety); /* 258 */ this.divider[0] = (this.tx / getSize().width); /* 259 */ this.divider[1] = (this.ty / getSize().height); /* 260 */ this.tx = Math.max(this.tx, this.minx); /* 261 */ this.ty = Math.max(this.ty, this.miny); /* 262 */ this.tx = Math.min(this.tx, this.maxx); /* 263 */ this.ty = Math.min(this.ty, this.maxy); /* 264 */ moveComponents(); /* */ } /* 266 */ return true; /* */ } /* */ /* */ public boolean mouseUp(Event evt, int x, int y) /* */ { /* 271 */ if (this.dragging) { /* 272 */ validate(); /* 273 */ saveLayout(); /* */ } /* 275 */ this.dragging = false; /* 276 */ return true; /* */ } /* */ /* */ /* */ public boolean mouseDown(Event evt, int x, int y) /* */ { /* 282 */ for (int i = 0; i < this.swaps.length; i++) /* 283 */ if (this.swaps[i].maybeSwap(x, y)) /* 284 */ return true; /* 285 */ if (this.moveWidget.contains(x, y)) { /* 286 */ this.offsetx = (this.tx - x); /* 287 */ this.offsety = (this.ty - y); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 296 */ this.minx = 12; /* 297 */ this.maxx = (getSize().width - this.minx); /* 298 */ this.miny = 12; /* 299 */ this.maxy = (getSize().height - this.miny); /* 300 */ if ((this.minx < this.maxx) && (this.miny < this.maxy)) /* 301 */ this.dragging = true; /* */ } /* 303 */ return true; /* */ } /* */ /* */ void swap(int c1, int c2) { /* 307 */ int tmp = this.order[c1]; /* 308 */ this.order[c1] = this.order[c2]; /* 309 */ this.order[c2] = tmp; /* 310 */ moveComponents(); /* 311 */ validate(); /* 312 */ saveLayout(); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\FourTilePanel.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */