-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCirSim.java
4968 lines (4538 loc) · 157 KB
/
CirSim.java
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) Paul Falstad and Iain Sharp
This file is part of CircuitJS1.
Version 4 by Vinyasi, 11/Mar/2018 23:11
BTW, 'Differential Equations' button has had its name changed
to 'Circuit Information'.
// Mod.Begin
// Mod.End
This file is part of Vinyasi's port of CircuitJS1 specializing in
Surge Circuits exhibiting Pure Resonance, aka Overunity and Free
Energy. See, Prof. Arthur Mattuck on YouTube and MIT Open Course
Ware. Also, Mathlets.org has a dynamic plot in JavaScript called:
Poles and Vibrations which comes closest to what I attempt to
engineer in all of my simulations whether or not I succeed.
http://mathlets.org/mathlets/poles-and-vibrations/
CircuitJS1 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
CircuitJS1 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CircuitJS1. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lushprojects.circuitjs1.client;
// GWT conversion (c) 2015 by Iain Sharp
// For information about the theory behind this, see Electronic Circuit & System Simulation Methods by Pillage
import java.util.Vector;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.lang.Math;
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CellPanel;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.canvas.dom.client.Context2d.LineCap;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseEvent;
import com.google.gwt.event.dom.client.MouseMoveEvent;
import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.google.gwt.event.dom.client.MouseWheelEvent;
import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.DoubleClickHandler;
import com.google.gwt.event.dom.client.DoubleClickEvent;
import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.storage.client.Storage;
import com.google.gwt.user.client.ui.PopupPanel;
import static com.google.gwt.event.dom.client.KeyCodes.*;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.Window.Navigator;
// Mod.Begin
//import java.util.Arrays;
// Mod.End
public class CirSim implements MouseDownHandler, MouseMoveHandler, MouseUpHandler,
ClickHandler, DoubleClickHandler, ContextMenuHandler, NativePreviewHandler,
MouseOutHandler, MouseWheelHandler {
Random random;
public static final int sourceRadius = 7;
public static final double freqMult = 3.14159265*2*4;
// IES - remove interaction
Button resetButton;
Button runStopButton;
// Mod.Begin
Button diffEqButton;
// Mod.End
Button dumpMatrixButton;
MenuItem aboutItem;
// Mod.Begin
MenuItem legendItem;
// Mod.End
MenuItem importFromLocalFileItem, importFromTextItem,
exportAsUrlItem, exportAsLocalFileItem, exportAsTextItem;
MenuItem importFromDropboxItem;
MenuItem exportToDropboxItem;
MenuItem undoItem, redoItem,
cutItem, copyItem, pasteItem, selectAllItem, optionsItem;
MenuBar optionsMenuBar;
CheckboxMenuItem dotsCheckItem;
CheckboxMenuItem voltsCheckItem;
CheckboxMenuItem powerCheckItem;
CheckboxMenuItem smallGridCheckItem;
CheckboxMenuItem crossHairCheckItem;
CheckboxMenuItem showValuesCheckItem;
CheckboxMenuItem conductanceCheckItem;
CheckboxMenuItem euroResistorCheckItem;
CheckboxMenuItem printableCheckItem;
CheckboxMenuItem conventionCheckItem;
private Label powerLabel;
private Label titleLabel;
private Scrollbar speedBar;
private Scrollbar currentBar;
private Scrollbar powerBar;
MenuBar elmMenuBar;
MenuItem elmEditMenuItem;
MenuItem elmCutMenuItem;
MenuItem elmCopyMenuItem;
MenuItem elmDeleteMenuItem;
MenuItem elmScopeMenuItem;
MenuItem elmFlipMenuItem;
MenuBar scopeMenuBar;
MenuBar transScopeMenuBar;
MenuBar mainMenuBar;
CheckboxMenuItem scopeVMenuItem;
CheckboxMenuItem scopeIMenuItem;
CheckboxMenuItem scopeScaleMenuItem;
CheckboxMenuItem scopeMaxMenuItem;
CheckboxMenuItem scopeMinMenuItem;
CheckboxMenuItem scopeFreqMenuItem;
CheckboxMenuItem scopeFFTMenuItem;
CheckboxMenuItem scopeRMSMenuItem;
CheckboxMenuItem scopePowerMenuItem;
CheckboxMenuItem scopeIbMenuItem;
CheckboxMenuItem scopeIcMenuItem;
CheckboxMenuItem scopeIeMenuItem;
CheckboxMenuItem scopeVbeMenuItem;
CheckboxMenuItem scopeVbcMenuItem;
CheckboxMenuItem scopeVceMenuItem;
CheckboxMenuItem scopeVIMenuItem;
CheckboxMenuItem scopeXYMenuItem;
CheckboxMenuItem scopeResistMenuItem;
CheckboxMenuItem scopeVceIcMenuItem;
CheckboxMenuItem scopeMaxScaleMenuItem;
CheckboxMenuItem scopeMaxScaleTransMenuItem;
MenuItem scopeRemovePlotMenuItem;
MenuItem scopeSelectYMenuItem;
static HashMap<String,String> localizationMap;
String lastCursorStyle;
boolean mouseWasOverSplitter = false;
// Class addingClass;
PopupPanel contextPanel = null;
int mouseMode = MODE_SELECT;
int tempMouseMode = MODE_SELECT;
String mouseModeStr = "Select";
static final double pi = 3.14159265358979323846;
static final int MODE_ADD_ELM = 0;
static final int MODE_DRAG_ALL = 1;
static final int MODE_DRAG_ROW = 2;
static final int MODE_DRAG_COLUMN = 3;
static final int MODE_DRAG_SELECTED = 4;
static final int MODE_DRAG_POST = 5;
static final int MODE_SELECT = 6;
static final int MODE_DRAG_SPLITTER = 7;
static final int infoWidth = 120;
long myframes =1;
long mytime=0;
long myruntime=0;
long mydrawtime=0;
int dragGridX, dragGridY, dragScreenX, dragScreenY, initDragGridX, initDragGridY;
long mouseDownTime;
long zoomTime;
int mouseCursorX = -1;
int mouseCursorY = -1;
int selectedSource;
Rectangle selectedArea;
int gridSize, gridMask, gridRound;
boolean dragging;
boolean analyzeFlag;
boolean dumpMatrix;
// boolean useBufferedImage;
boolean isMac;
String ctrlMetaKey;
double t;
int pause = 10;
int scopeSelected = -1;
int menuScope = -1;
int menuPlot = -1;
int hintType = -1, hintItem1, hintItem2;
String stopMessage;
double timeStep;
static final int HINT_LC = 1;
static final int HINT_RC = 2;
static final int HINT_3DB_C = 3;
static final int HINT_TWINT = 4;
static final int HINT_3DB_L = 5;
Vector<CircuitElm> elmList;
// Vector setupList;
CircuitElm dragElm, menuElm, stopElm;
private CircuitElm mouseElm=null;
boolean didSwitch = false;
int mousePost = -1;
CircuitElm plotXElm, plotYElm;
int draggingPost;
SwitchElm heldSwitchElm;
double circuitMatrix[][], circuitRightSide[],
origRightSide[], origMatrix[][];
RowInfo circuitRowInfo[];
int circuitPermute[];
boolean simRunning;
boolean circuitNonLinear;
int voltageSourceCount;
int circuitMatrixSize, circuitMatrixFullSize;
boolean circuitNeedsMap;
// public boolean useFrame;
int scopeCount;
Scope scopes[];
boolean showResistanceInVoltageSources;
int scopeColCount[];
static EditDialog editDialog, customLogicEditDialog;
static ExportAsUrlDialog exportAsUrlDialog;
static ExportAsTextDialog exportAsTextDialog;
static ExportAsLocalFileDialog exportAsLocalFileDialog;
static ImportFromTextDialog importFromTextDialog;
static ImportFromDropbox importFromDropbox;
static ExportToDropbox exportToDropbox;
static ScrollValuePopup scrollValuePopup;
static AboutBox aboutBox;
// Mod.Begin
static LegendBox legendBox;
static AboutDiffEqBox aboutDiffEq;
// static FalstadCircuits falstadMenubar;
// static VinyasiCircuits vinyasiMenubar;
// Mod.End
static ImportFromDropboxDialog importFromDropboxDialog;
// Class dumpTypes[], shortcuts[];
String shortcuts[];
static String muString = "\u03bc";
static String ohmString = "\u03a9";
String clipboard;
Rectangle circuitArea;
Vector<String> undoStack, redoStack;
double transform[];
DockLayoutPanel layoutPanel;
MenuBar menuBar;
MenuBar fileMenuBar;
VerticalPanel verticalPanel;
CellPanel buttonPanel;
// Mod.Begin
String file;
CellPanel diffEqPanel;
// Mod.End
private boolean mouseDragging;
double scopeHeightFraction=0.2;
Vector<CheckboxMenuItem> mainMenuItems = new Vector<CheckboxMenuItem>();
Vector<String> mainMenuItemNames = new Vector<String>();
LoadFile loadFileInput;
Frame iFrame;
Canvas cv;
Context2d cvcontext;
Canvas backcv;
Context2d backcontext;
static final int MENUBARHEIGHT=30;
static int VERTICALPANELWIDTH=166; // default
static final int POSTGRABSQ=25;
static final int MINPOSTGRABSIZE = 256;
final Timer timer = new Timer() {
public void run() {
updateCircuit();
}
};
final int FASTTIMER=16;
int getrand(int x) {
int q = random.nextInt();
if (q < 0)
q = -q;
return q % x;
}
public void setCanvasSize(){
int width, height;
width=(int)RootLayoutPanel.get().getOffsetWidth();
height=(int)RootLayoutPanel.get().getOffsetHeight();
height=height-MENUBARHEIGHT;
width=width-VERTICALPANELWIDTH;
if (cv != null) {
cv.setWidth(width + "PX");
cv.setHeight(height + "PX");
cv.setCoordinateSpaceWidth(width);
cv.setCoordinateSpaceHeight(height);
}
if (backcv != null) {
backcv.setWidth(width + "PX");
backcv.setHeight(height + "PX");
backcv.setCoordinateSpaceWidth(width);
backcv.setCoordinateSpaceHeight(height);
}
setCircuitArea();
}
void setCircuitArea() {
int height = cv.getCanvasElement().getHeight();
int width = cv.getCanvasElement().getWidth();
int h = (int) ((double)height * scopeHeightFraction);
/*if (h < 128 && winSize.height > 300)
h = 128;*/
circuitArea = new Rectangle(0, 0, width, height-h);
}
// Circuit applet;
CirSim() {
// super("Circuit Simulator v1.6d");
// applet = a;
// useFrame = false;
theSim = this;
}
// Mod.Begin
String titleNobility = "";
String titleNobilitySize = "small";
// Mod.End
String startCircuit = null;
String startLabel = null;
String startCircuitText = null;
String startCircuitLink = null;
// String baseURL = "http://www.falstad.com/circuit/";
public void init() {
boolean printable = false;
boolean convention = true;
boolean euroRes = false;
boolean usRes = false;
MenuBar m;
CircuitElm.initClass(this);
QueryParameters qp = new QueryParameters();
try {
//baseURL = applet.getDocumentBase().getFile();
// look for circuit embedded in URL
// String doc = applet.getDocumentBase().toString();
String cct=qp.getValue("cct");
if (cct!=null)
startCircuitText = cct.replace("%24", "$");
startCircuit = qp.getValue("startCircuit");
startLabel = qp.getValue("startLabel");
startCircuitLink = qp.getValue("startCircuitLink");
euroRes = qp.getBooleanValue("euroResistors", false);
usRes = qp.getBooleanValue("usResistors", false);
printable = qp.getBooleanValue("whiteBackground", getOptionFromStorage("whiteBackground", false));
convention = qp.getBooleanValue("conventionalCurrent",
getOptionFromStorage("conventionalCurrent", true));
} catch (Exception e) { }
boolean euroSetting = false;
if (euroRes)
euroSetting = true;
else if (usRes)
euroSetting = false;
else
euroSetting = getOptionFromStorage("euroResistors", !weAreInUS());
transform = new double[6];
String os = Navigator.getPlatform();
isMac = (os.toLowerCase().contains("mac"));
ctrlMetaKey = (isMac) ? "Cmd" : "Ctrl";
shortcuts = new String[127];
layoutPanel = new DockLayoutPanel(Unit.PX);
fileMenuBar = new MenuBar(true);
importFromLocalFileItem = new MenuItem(LS("Import From Local File"), new MyCommand("file","importfromlocalfile"));
importFromLocalFileItem.setEnabled(LoadFile.isSupported());
fileMenuBar.addItem(importFromLocalFileItem);
importFromTextItem = new MenuItem(LS("Import From Text"), new MyCommand("file","importfromtext"));
fileMenuBar.addItem(importFromTextItem);
importFromDropboxItem = new MenuItem(LS("Import From Dropbox"), new MyCommand("file", "importfromdropbox"));
fileMenuBar.addItem(importFromDropboxItem);
exportAsUrlItem = new MenuItem(LS("Export As Link"), new MyCommand("file","exportasurl"));
fileMenuBar.addItem(exportAsUrlItem);
exportAsLocalFileItem = new MenuItem(LS("Export As Local File"), new MyCommand("file","exportaslocalfile"));
exportAsLocalFileItem.setEnabled(ExportAsLocalFileDialog.downloadIsSupported());
fileMenuBar.addItem(exportAsLocalFileItem);
exportAsTextItem = new MenuItem(LS("Export As Text"), new MyCommand("file","exportastext"));
fileMenuBar.addItem(exportAsTextItem);
exportToDropboxItem = new MenuItem(LS("Export To Dropbox"), new MyCommand("file", "exporttodropbox"));
exportToDropboxItem.setEnabled(ExportToDropbox.isSupported());
fileMenuBar.addItem(exportToDropboxItem);
fileMenuBar.addSeparator();
// Mod.Begin
legendItem=new MenuItem(LS("Legend of Symbols"),(Command)null);
fileMenuBar.addItem(legendItem);
legendItem.setScheduledCommand(new MyCommand("file","legend"));
// Mod.End
aboutItem=new MenuItem(LS("About this Software"),(Command)null);
fileMenuBar.addItem(aboutItem);
aboutItem.setScheduledCommand(new MyCommand("file","about"));
int width=(int)RootLayoutPanel.get().getOffsetWidth();
VERTICALPANELWIDTH = width/5;
if (VERTICALPANELWIDTH > 166)
VERTICALPANELWIDTH = 166;
if (VERTICALPANELWIDTH < 128)
VERTICALPANELWIDTH = 128;
menuBar = new MenuBar();
menuBar.addItem(LS("File"), fileMenuBar);
verticalPanel=new VerticalPanel();
// make buttons side by side if there's room
buttonPanel=(VERTICALPANELWIDTH == 166) ? new HorizontalPanel() : new VerticalPanel();
// Mod.Begin
diffEqPanel=(VERTICALPANELWIDTH == 166) ? new HorizontalPanel() : new VerticalPanel();
// Mod.End
m = new MenuBar(true);
m.addItem(undoItem = menuItemWithShortcut(LS("Undo"), LS("Ctrl-Z"), new MyCommand("edit","undo")));
m.addItem(redoItem = menuItemWithShortcut(LS("Redo"), LS("Ctrl-Y"), new MyCommand("edit","redo")));
m.addSeparator();
m.addItem(cutItem = menuItemWithShortcut(LS("Cut"), LS("Ctrl-X"), new MyCommand("edit","cut")));
m.addItem(copyItem = menuItemWithShortcut(LS("Copy"), LS("Ctrl-C"), new MyCommand("edit","copy")));
m.addItem(pasteItem = menuItemWithShortcut(LS("Paste"), LS("Ctrl-V"), new MyCommand("edit","paste")));
pasteItem.setEnabled(false);
m.addItem(menuItemWithShortcut(LS("Duplicate"), LS("Ctrl-D"), new MyCommand("edit","duplicate")));
m.addSeparator();
m.addItem(selectAllItem = menuItemWithShortcut(LS("Select All"), LS("Ctrl-A"), new MyCommand("edit","selectAll")));
m.addSeparator();
m.addItem(new MenuItem(weAreInUS() ? LS("Center Circuit") : LS("Centre Circuit"), new MyCommand("edit", "centrecircuit")));
m.addItem(menuItemWithShortcut(LS("Zoom 100%"), "0", new MyCommand("edit", "zoom100")));
m.addItem(menuItemWithShortcut(LS("Zoom In"), "+", new MyCommand("edit", "zoomin")));
m.addItem(menuItemWithShortcut(LS("Zoom Out"), "-", new MyCommand("edit", "zoomout")));
menuBar.addItem(LS("Edit"),m);
MenuBar drawMenuBar = new MenuBar(true);
drawMenuBar.setAutoOpen(true);
menuBar.addItem(LS("Draw"), drawMenuBar);
m = new MenuBar(true);
m.addItem(new MenuItem(LS("Stack All"), new MyCommand("scopes", "stackAll")));
m.addItem(new MenuItem(LS("Unstack All"),new MyCommand("scopes", "unstackAll")));
m.addItem(new MenuItem(LS("Combine All"),new MyCommand("scopes", "combineAll")));
menuBar.addItem(LS("Scopes"), m);
optionsMenuBar = m = new MenuBar(true );
menuBar.addItem(LS("Options"), optionsMenuBar);
m.addItem(dotsCheckItem = new CheckboxMenuItem(LS("Show Current")));
dotsCheckItem.setState(true);
m.addItem(voltsCheckItem = new CheckboxMenuItem(LS("Show Voltage"),
new Command() { public void execute(){
if (voltsCheckItem.getState())
powerCheckItem.setState(false);
setPowerBarEnable();
}
}));
voltsCheckItem.setState(true);
m.addItem(powerCheckItem = new CheckboxMenuItem(LS("Show Power"),
new Command() { public void execute(){
if (powerCheckItem.getState())
voltsCheckItem.setState(false);
setPowerBarEnable();
}
}));
m.addItem(showValuesCheckItem = new CheckboxMenuItem(LS("Show Values")));
showValuesCheckItem.setState(true);
//m.add(conductanceCheckItem = getCheckItem(LS("Show Conductance")));
m.addItem(smallGridCheckItem = new CheckboxMenuItem(LS("Small Grid"),
new Command() { public void execute(){
setGrid();
}
}));
m.addItem(crossHairCheckItem = new CheckboxMenuItem(LS("Show Cursor Cross Hairs"),
new Command() { public void execute(){
setOptionInStorage("crossHair", crossHairCheckItem.getState());
}
}));
crossHairCheckItem.setState(getOptionFromStorage("crossHair", false));
m.addItem(euroResistorCheckItem = new CheckboxMenuItem(LS("European Resistors"),
new Command() { public void execute(){
setOptionInStorage("euroResistors", euroResistorCheckItem.getState());
}
}));
euroResistorCheckItem.setState(euroSetting);
m.addItem(printableCheckItem = new CheckboxMenuItem(LS("White Background"),
new Command() { public void execute(){
int i;
for (i=0;i<scopeCount;i++)
scopes[i].setRect(scopes[i].rect);
setOptionInStorage("whiteBackground", printableCheckItem.getState());
}
}));
printableCheckItem.setState(printable);
m.addItem(conventionCheckItem = new CheckboxMenuItem(LS("Conventional Current Motion"),
new Command() { public void execute(){
setOptionInStorage("conventionalCurrent", conventionCheckItem.getState());
}
}));
conventionCheckItem.setState(convention);
m.addItem(optionsItem = new CheckboxAlignedMenuItem(LS("Other Options..."),
new MyCommand("options","other")));
/*
// Mod.Begin
// If I were to insert an array for building a menubar loaded
// from a plain text file, then I would probably put it here.
falstadCircuitsList[0][0]
vinyasiCircuitsList[0][0]
// Mod.End
*/
mainMenuBar = new MenuBar(true);
mainMenuBar.setAutoOpen(true);
composeMainMenu(mainMenuBar);
composeMainMenu(drawMenuBar);
layoutPanel.addNorth(menuBar, MENUBARHEIGHT);
layoutPanel.addEast(verticalPanel, VERTICALPANELWIDTH);
RootLayoutPanel.get().add(layoutPanel);
cv =Canvas.createIfSupported();
if (cv==null) {
RootPanel.get().add(new Label("Not working. You need a browser that supports the CANVAS element."));
return;
}
cvcontext=cv.getContext2d();
backcv=Canvas.createIfSupported();
backcontext=backcv.getContext2d();
setCanvasSize();
layoutPanel.add(cv);
verticalPanel.add(buttonPanel);
buttonPanel.add(resetButton = new Button(LS("Reset")));
resetButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
resetAction();
}
});
resetButton.setStylePrimaryName("topButton");
buttonPanel.add(runStopButton = new Button(LSHTML("<Strong>RUN</Strong> / Stop")));
runStopButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setSimRunning(!simIsRunning());
}
});
// Mod.Begin
verticalPanel.add(diffEqPanel);
diffEqPanel.add(diffEqButton = new Button(LSHTML("Circuit Information")));
diffEqButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
aboutDiffEq = new AboutDiffEqBox(titleNobility, titleNobilitySize);
}
});
diffEqButton.setStylePrimaryName("topButton-invisible");
// Mod.End
/*
dumpMatrixButton = new Button("Dump Matrix");
dumpMatrixButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) { dumpMatrix = true; }});
verticalPanel.add(dumpMatrixButton);// IES for debugging
*/
if (LoadFile.isSupported())
verticalPanel.add(loadFileInput = new LoadFile(this));
Label l;
verticalPanel.add(l = new Label(LS("Simulation Speed")));
l.addStyleName("topSpace");
// was max of 140
verticalPanel.add( speedBar = new Scrollbar(Scrollbar.HORIZONTAL, 3, 1, 0, 260));
verticalPanel.add( l = new Label(LS("Current Speed")));
l.addStyleName("topSpace");
currentBar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 100);
verticalPanel.add(currentBar);
verticalPanel.add(powerLabel = new Label (LS("Power Brightness")));
powerLabel.addStyleName("topSpace");
verticalPanel.add(powerBar = new Scrollbar(Scrollbar.HORIZONTAL,
50, 1, 1, 100));
setPowerBarEnable();
// verticalPanel.add(new Label(""));
// Font f = new Font("SansSerif", 0, 10);
l = new Label(LS("Current Circuit:"));
l.addStyleName("topSpace");
// l.setFont(f);
titleLabel = new Label("Label");
// titleLabel.setFont(f);
verticalPanel.add(l);
verticalPanel.add(titleLabel);
verticalPanel.add(iFrame = new Frame("iframe.html"));
iFrame.setWidth(VERTICALPANELWIDTH+"px");
iFrame.setHeight("100 px");
// Mod.Begin
iFrame.getElement().setAttribute("scrolling", "yes");
// Mod.End
setGrid();
elmList = new Vector<CircuitElm>();
// setupList = new Vector();
undoStack = new Vector<String>();
redoStack = new Vector<String>();
scopes = new Scope[20];
scopeColCount = new int[20];
scopeCount = 0;
random = new Random();
// cv.setBackground(Color.black);
// cv.setForeground(Color.lightGray);
elmMenuBar = new MenuBar(true);
elmMenuBar.addItem(elmEditMenuItem = new MenuItem(LS("Edit"),new MyCommand("elm","edit")));
elmMenuBar.addItem(elmScopeMenuItem = new MenuItem(LS("View in Scope"), new MyCommand("elm","viewInScope")));
elmMenuBar.addItem(elmCutMenuItem = new MenuItem(LS("Cut"),new MyCommand("elm","cut")));
elmMenuBar.addItem(elmCopyMenuItem = new MenuItem(LS("Copy"),new MyCommand("elm","copy")));
elmMenuBar.addItem(elmDeleteMenuItem = new MenuItem(LS("Delete"),new MyCommand("elm","delete")));
elmMenuBar.addItem( new MenuItem(LS("Duplicate"),new MyCommand("elm","duplicate")));
elmMenuBar.addItem(elmFlipMenuItem = new MenuItem(LS("Swap Terminals"),new MyCommand("elm","flip")));
scopeMenuBar = buildScopeMenu(false);
transScopeMenuBar = buildScopeMenu(true);
// Mod.Begin
if (startCircuitText != null) {
// entire circuit loads embedded in a long link
getSetupListFalstad(false);
readSetup(startCircuitText, true);
} else {
// load circuit from Dropbox
if (stopMessage == null && startCircuitLink!=null) {
readSetup(null, 0, false, true);
getSetupListFalstad(false);
ImportFromDropboxDialog.setSim(this);
ImportFromDropboxDialog.doImportDropboxLink(startCircuitLink, false);
} else {
// load circuit from filename in link
readSetup(null, 0, false, true);
if (stopMessage == null && startCircuit != null) {
getSetupListFalstad(true);
}
else
// load default circuit
getSetupListFalstad(true);
}
}
if (startCircuitText != null) {
// entire circuit loads embedded in a long link
getSetupListVinyasi(false);
readSetup(startCircuitText, true);
} else {
// load circuit from Dropbox
if (stopMessage == null && startCircuitLink!=null) {
readSetup(null, 0, false, true);
getSetupListVinyasi(false);
ImportFromDropboxDialog.setSim(this);
ImportFromDropboxDialog.doImportDropboxLink(startCircuitLink, false);
} else {
// load circuit from filename in link
readSetup(null, 0, false, true);
if (stopMessage == null && startCircuit != null) {
getSetupListVinyasi(true);
}
else
// load default circuit
getSetupListVinyasi(true);
}
}
// Mod.End
enableUndoRedo();
enablePaste();
setiFrameHeight();
cv.addMouseDownHandler(this);
cv.addMouseMoveHandler(this);
cv.addMouseOutHandler(this);
cv.addMouseUpHandler(this);
cv.addClickHandler(this);
cv.addDoubleClickHandler(this);
doTouchHandlers(cv.getCanvasElement());
cv.addDomHandler(this, ContextMenuEvent.getType());
menuBar.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
doMainMenuChecks();
}
}, ClickEvent.getType());
Event.addNativePreviewHandler(this);
cv.addMouseWheelHandler(this);
setSimRunning(true);
// setup timer
timer.scheduleRepeating(FASTTIMER);
}
MenuItem menuItemWithShortcut(String text, String shortcut, MyCommand cmd) {
final String edithtml="<div style=\"display:inline-block;width:80px;\">";
String sn=edithtml + text + "</div>" + shortcut;
return new MenuItem(SafeHtmlUtils.fromTrustedString(sn), cmd);
}
boolean getOptionFromStorage(String key, boolean val) {
Storage stor = Storage.getLocalStorageIfSupported();
if (stor == null)
return val;
String s = stor.getItem(key);
if (s == null)
return val;
return s == "true";
}
void setOptionInStorage(String key, boolean val) {
Storage stor = Storage.getLocalStorageIfSupported();
if (stor == null)
return;
stor.setItem(key, val ? "true" : "false");
}
// install touch handlers
// don't feel like rewriting this in java. Anyway, java doesn't let us create mouse
// events and dispatch them.
native void doTouchHandlers(CanvasElement cv) /*-{
// Set up touch events for mobile, etc
var lastTap;
var tmout;
var sim = this;
cv.addEventListener("touchstart", function (e) {
mousePos = getTouchPos(cv, e);
var touch = e.touches[0];
var etype = "mousedown";
clearTimeout(tmout);
if (e.timeStamp-lastTap < 300) {
etype = "dblclick";
} else {
tmout = setTimeout(function() {
[email protected]::longPress()();
}, 500);
}
lastTap = e.timeStamp;
var mouseEvent = new MouseEvent(etype, {
clientX: touch.clientX,
clientY: touch.clientY
});
e.preventDefault();
cv.dispatchEvent(mouseEvent);
}, false);
cv.addEventListener("touchend", function (e) {
var mouseEvent = new MouseEvent("mouseup", {});
e.preventDefault();
clearTimeout(tmout);
cv.dispatchEvent(mouseEvent);
}, false);
cv.addEventListener("touchmove", function (e) {
var touch = e.touches[0];
var mouseEvent = new MouseEvent("mousemove", {
clientX: touch.clientX,
clientY: touch.clientY
});
e.preventDefault();
clearTimeout(tmout);
cv.dispatchEvent(mouseEvent);
}, false);
// Get the position of a touch relative to the canvas
function getTouchPos(canvasDom, touchEvent) {
var rect = canvasDom.getBoundingClientRect();
return {
x: touchEvent.touches[0].clientX - rect.left,
y: touchEvent.touches[0].clientY - rect.top
};
}
}-*/;
boolean shown = false;
public void composeMainMenu(MenuBar mainMenuBar) {
mainMenuBar.addItem(getClassCheckItem(LS("Add Wire"), "WireElm"));
mainMenuBar.addItem(getClassCheckItem(LS("Add Resistor"), "ResistorElm"));
MenuBar passMenuBar = new MenuBar(true);
passMenuBar.addItem(getClassCheckItem(LS("Add Capacitor"), "CapacitorElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Capacitor (polarized)"), "PolarCapacitorElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Inductor"), "InductorElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Switch"), "SwitchElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Push Switch"), "PushSwitchElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add SPDT Switch"), "Switch2Elm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Potentiometer"), "PotElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Transformer"), "TransformerElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Tapped Transformer"), "TappedTransformerElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Transmission Line"), "TransLineElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Relay"), "RelayElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Memristor"), "MemristorElm"));
passMenuBar.addItem(getClassCheckItem(LS("Add Spark Gap"), "SparkGapElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Passive Components")), passMenuBar);
MenuBar inputMenuBar = new MenuBar(true);
inputMenuBar.addItem(getClassCheckItem(LS("Add Ground"), "GroundElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Voltage Source (2-terminal)"), "DCVoltageElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add A/C Voltage Source (2-terminal)"), "ACVoltageElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Voltage Source (1-terminal)"), "RailElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add A/C Voltage Source (1-terminal)"), "ACRailElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Square Wave Source (1-terminal)"), "SquareRailElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Clock"), "ClockElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add A/C Sweep"), "SweepElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Variable Voltage"), "VarRailElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Antenna"), "AntennaElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add AM Source"), "AMElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add FM Source"), "FMElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Current Source"), "CurrentElm"));
inputMenuBar.addItem(getClassCheckItem(LS("Add Noise Generator"), "NoiseElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Inputs and Sources")), inputMenuBar);
MenuBar outputMenuBar = new MenuBar(true);
outputMenuBar.addItem(getClassCheckItem(LS("Add Analog Output"), "OutputElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add LED"), "LEDElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Lamp"), "LampElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Text"), "TextElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Box"), "BoxElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Voltmeter/Scobe Probe"), "ProbeElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Labeled Node"), "LabeledNodeElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Test Point"), "TestPointElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Ammeter"), "AmmeterElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Data Export"), "DataRecorderElm"));
outputMenuBar.addItem(getClassCheckItem(LS("Add Audio Output"), "AudioOutputElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Outputs and Labels")), outputMenuBar);
MenuBar activeMenuBar = new MenuBar(true);
activeMenuBar.addItem(getClassCheckItem(LS("Add Diode"), "DiodeElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Zener Diode"), "ZenerElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Transistor (bipolar, NPN)"), "NTransistorElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Transistor (bipolar, PNP)"), "PTransistorElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add MOSFET (N-Channel)"), "NMosfetElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add MOSFET (P-Channel)"), "PMosfetElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add JFET (N-Channel)"), "NJfetElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add JFET (P-Channel)"), "PJfetElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add SCR"), "SCRElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Darlington Pair (NPN)"), "NDarlingtonElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Darlington Pair (PNP)"), "PDarlingtonElm"));
// activeMenuBar.addItem(getClassCheckItem("Add Varactor/Varicap", "VaractorElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Tunnel Diode"), "TunnelDiodeElm"));
activeMenuBar.addItem(getClassCheckItem(LS("Add Triode"), "TriodeElm"));
// activeMenuBar.addItem(getClassCheckItem("Add Diac", "DiacElm"));
// activeMenuBar.addItem(getClassCheckItem("Add Triac", "TriacElm"));
// activeMenuBar.addItem(getClassCheckItem("Add Photoresistor", "PhotoResistorElm"));
// activeMenuBar.addItem(getClassCheckItem("Add Thermistor", "ThermistorElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Active Components")), activeMenuBar);
MenuBar activeBlocMenuBar = new MenuBar(true);
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Op Amp (- on top)"), "OpAmpElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Op Amp (+ on top)"), "OpAmpSwapElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Analog Switch (SPST)"), "AnalogSwitchElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Analog Switch (SPDT)"), "AnalogSwitch2Elm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Tristate Buffer"), "TriStateElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Schmitt Trigger"), "SchmittElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Schmitt Trigger (Inverting)"), "InvertingSchmittElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add CCII+"), "CC2Elm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add CCII-"), "CC2NegElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Comparator (Hi-Z/GND output)"), "ComparatorElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add OTA (LM13700 style)"), "OTAElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Voltage-Controlled Voltage Source"), "VCVSElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Voltage-Controlled Current Source"), "VCCSElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Current-Controlled Voltage Source"), "CCVSElm"));
activeBlocMenuBar.addItem(getClassCheckItem(LS("Add Current-Controlled Current Source"), "CCCSElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Active Building Blocks")), activeBlocMenuBar);
MenuBar gateMenuBar = new MenuBar(true);
gateMenuBar.addItem(getClassCheckItem(LS("Add Logic Input"), "LogicInputElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add Logic Output"), "LogicOutputElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add Inverter"), "InverterElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add NAND Gate"), "NandGateElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add NOR Gate"), "NorGateElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add AND Gate"), "AndGateElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add OR Gate"), "OrGateElm"));
gateMenuBar.addItem(getClassCheckItem(LS("Add XOR Gate"), "XorGateElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Logic Gates, Input and Output")), gateMenuBar);
MenuBar chipMenuBar = new MenuBar(true);
chipMenuBar.addItem(getClassCheckItem(LS("Add D Flip-Flop"), "DFlipFlopElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add JK Flip-Flop"), "JKFlipFlopElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add T Flip-Flop"), "TFlipFlopElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add 7 Segment LED"), "SevenSegElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add 7 Segment Decoder"), "SevenSegDecoderElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Multiplexer"), "MultiplexerElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Demultiplexer"), "DeMultiplexerElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add SIPO shift register"), "SipoShiftElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add PISO shift register"), "PisoShiftElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Counter"), "CounterElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Decade Counter"), "DecadeElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Latch"), "LatchElm"));
//chipMenuBar.addItem(getClassCheckItem("Add Static RAM", "SRAMElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Sequence generator"), "SeqGenElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Full Adder"), "FullAdderElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Half Adder"), "HalfAdderElm"));
chipMenuBar.addItem(getClassCheckItem(LS("Add Custom Logic"), "UserDefinedLogicElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Digital Chips")), chipMenuBar);
MenuBar achipMenuBar = new MenuBar(true);
achipMenuBar.addItem(getClassCheckItem(LS("Add 555 Timer"), "TimerElm"));
achipMenuBar.addItem(getClassCheckItem(LS("Add Phase Comparator"), "PhaseCompElm"));
achipMenuBar.addItem(getClassCheckItem(LS("Add DAC"), "DACElm"));
achipMenuBar.addItem(getClassCheckItem(LS("Add ADC"), "ADCElm"));
achipMenuBar.addItem(getClassCheckItem(LS("Add VCO"), "VCOElm"));
achipMenuBar.addItem(getClassCheckItem(LS("Add Monostable"), "MonostableElm"));
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Analog and Hybrid Chips")), achipMenuBar);
MenuBar otherMenuBar = new MenuBar(true);
CheckboxMenuItem mi;
otherMenuBar.addItem(mi=getClassCheckItem(LS("Drag All"), "DragAll"));
mi.addShortcut(LS("(Alt-drag)"));
otherMenuBar.addItem(mi=getClassCheckItem(LS("Drag Row"), "DragRow"));
mi.addShortcut(LS("(A-S-drag)"));
otherMenuBar.addItem(mi=getClassCheckItem(LS("Drag Column"), "DragColumn"));
mi.addShortcut(isMac ? LS("(A-Cmd-drag)") : LS("(A-M-drag)"));
otherMenuBar.addItem(getClassCheckItem(LS("Drag Selected"), "DragSelected"));
otherMenuBar.addItem(mi=getClassCheckItem(LS("Drag Post"), "DragPost"));
mi.addShortcut("(" + ctrlMetaKey + "-drag)");
mainMenuBar.addItem(SafeHtmlUtils.fromTrustedString(CheckboxMenuItem.checkBoxHtml+LS(" </div>Drag")), otherMenuBar);
mainMenuBar.addItem(mi=getClassCheckItem(LS("Select/Drag Sel"), "Select"));
mi.addShortcut(LS("(space or Shift-drag)"));
}
public void setiFrameHeight() {
if (iFrame==null)
return;
int i;
int cumheight=0;
for (i=0; i < verticalPanel.getWidgetIndex(iFrame); i++) {
if (verticalPanel.getWidget(i) !=loadFileInput) {
cumheight=cumheight+verticalPanel.getWidget(i).getOffsetHeight();
if (verticalPanel.getWidget(i).getStyleName().contains("topSpace"))
cumheight+=12;
}
}
int ih=RootLayoutPanel.get().getOffsetHeight()-MENUBARHEIGHT-cumheight;