/
LayoutEditor.java
10939 lines (9431 loc) · 427 KB
/
LayoutEditor.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
package jmri.jmrit.display.layoutEditor;
import apps.gui.GuiLafPreferencesManager;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.io.File;
import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import jmri.Block;
import jmri.BlockManager;
import jmri.ConfigureManager;
import jmri.InstanceManager;
import jmri.InvokeOnGuiThread;
import jmri.JmriException;
import jmri.Memory;
import jmri.MemoryManager;
import jmri.NamedBean;
import jmri.Reporter;
import jmri.ReporterManager;
import jmri.Sensor;
import jmri.SensorManager;
import jmri.SignalHead;
import jmri.SignalHeadManager;
import jmri.SignalMast;
import jmri.SignalMastLogic;
import jmri.SignalMastLogicManager;
import jmri.SignalMastManager;
import jmri.TransitManager;
import jmri.Turnout;
import jmri.UserPreferencesManager;
import jmri.configurexml.StoreXmlUserAction;
import jmri.jmrit.catalog.NamedIcon;
import jmri.jmrit.dispatcher.DispatcherAction;
import jmri.jmrit.dispatcher.DispatcherFrame;
import jmri.jmrit.display.AnalogClock2Display;
import jmri.jmrit.display.Editor;
import jmri.jmrit.display.LocoIcon;
import jmri.jmrit.display.MultiSensorIcon;
import jmri.jmrit.display.PanelMenu;
import jmri.jmrit.display.Positionable;
import jmri.jmrit.display.PositionableJComponent;
import jmri.jmrit.display.PositionableLabel;
import jmri.jmrit.display.PositionablePopupUtil;
import jmri.jmrit.display.ReporterIcon;
import jmri.jmrit.display.SensorIcon;
import jmri.jmrit.display.SignalHeadIcon;
import jmri.jmrit.display.SignalMastIcon;
import jmri.jmrit.display.ToolTip;
import jmri.jmrit.display.panelEditor.PanelEditor;
import jmri.jmrit.entryexit.AddEntryExitPairAction;
import jmri.swing.NamedBeanComboBox;
import jmri.util.ColorUtil;
import jmri.util.FileChooserFilter;
import jmri.util.FileUtil;
import jmri.util.JmriJFrame;
import jmri.util.MathUtil;
import jmri.util.SystemType;
import jmri.util.swing.JComboBoxUtil;
import jmri.util.swing.JmriColorChooser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Provides a scrollable Layout Panel and editor toolbars (that can be hidden)
* <p>
* This module serves as a manager for the LayoutTurnout, Layout Block,
* PositionablePoint, Track Segment, LayoutSlip and LevelXing objects which are
* integral subparts of the LayoutEditor class.
* <p>
* All created objects are put on specific levels depending on their type
* (higher levels are in front): Note that higher numbers appear behind lower
* numbers.
* <p>
* The "contents" List keeps track of all text and icon label objects added to
* the target frame for later manipulation. Other Lists keep track of drawn
* items.
* <p>
* Based in part on PanelEditor.java (Bob Jacobsen (c) 2002, 2003). In
* particular, text and icon label items are copied from Panel editor, as well
* as some of the control design.
*
* @author Dave Duchamp Copyright: (c) 2004-2007
* @author George Warner Copyright: (c) 2017
*/
@SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED") //no Serializable support at present
public class LayoutEditor extends PanelEditor implements MouseWheelListener {
//Operational instance variables - not saved to disk
private transient JmriJFrame floatingEditToolBoxFrame = null;
private transient JScrollPane floatingEditContentScrollPane = null;
private transient JPanel floatEditHelpPanel = null;
private transient JPanel editToolBarPanel = null;
private transient JScrollPane editToolBarScrollPane = null;
private transient JPanel editToolBarContainerPanel = null;
private transient JPanel helpBarPanel = null;
private transient JPanel helpBar = new JPanel();
private transient boolean editorUseOldLocSize;
private transient Font toolBarFont = null;
private transient ButtonGroup itemGroup = null;
//top row of radio buttons
private transient JLabel turnoutLabel = new JLabel();
private transient JRadioButton turnoutRHButton = new JRadioButton(Bundle.getMessage("RightHandAbbreviation"));
private transient JRadioButton turnoutLHButton = new JRadioButton(Bundle.getMessage("LeftHandAbbreviation"));
private transient JRadioButton turnoutWYEButton = new JRadioButton(Bundle.getMessage("WYEAbbreviation"));
private transient JRadioButton doubleXoverButton = new JRadioButton(Bundle.getMessage("DoubleCrossoverAbbreviation"));
private transient JRadioButton rhXoverButton = new JRadioButton(Bundle.getMessage("RightCrossover")); //key is also used by Control Panel
//Editor, placed in DisplayBundle
private transient JRadioButton lhXoverButton = new JRadioButton(Bundle.getMessage("LeftCrossover")); //idem
private transient JRadioButton layoutSingleSlipButton = new JRadioButton(Bundle.getMessage("LayoutSingleSlip"));
private transient JRadioButton layoutDoubleSlipButton = new JRadioButton(Bundle.getMessage("LayoutDoubleSlip"));
//Default flow layout definitions for JPanels
private transient FlowLayout leftRowLayout = new FlowLayout(FlowLayout.LEFT, 5, 0); //5 pixel gap between items, no vertical gap
private transient FlowLayout centerRowLayout = new FlowLayout(FlowLayout.CENTER, 5, 0); //5 pixel gap between items, no vertical gap
private transient FlowLayout rightRowLayout = new FlowLayout(FlowLayout.RIGHT, 5, 0); //5 pixel gap between items, no vertical gap
//top row of check boxes
private transient NamedBeanComboBox<Turnout> turnoutNameComboBox = new NamedBeanComboBox<>(
InstanceManager.turnoutManagerInstance(), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JPanel turnoutNamePanel = new JPanel(leftRowLayout);
private transient JPanel extraTurnoutPanel = new JPanel(leftRowLayout);
private transient NamedBeanComboBox<Turnout> extraTurnoutNameComboBox = new NamedBeanComboBox<>(
InstanceManager.turnoutManagerInstance(), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JComboBox<String> rotationComboBox = null;
private transient JPanel rotationPanel = new JPanel(leftRowLayout);
//2nd row of radio buttons
private transient JLabel trackLabel = new JLabel();
private transient JRadioButton levelXingButton = new JRadioButton(Bundle.getMessage("LevelCrossing"));
private transient JRadioButton trackButton = new JRadioButton(Bundle.getMessage("TrackSegment"));
//2nd row of check boxes
private transient JPanel trackSegmentPropertiesPanel = new JPanel(leftRowLayout);
private transient JCheckBox mainlineTrack = new JCheckBox(Bundle.getMessage("MainlineBox"));
private transient JCheckBox dashedLine = new JCheckBox(Bundle.getMessage("Dashed"));
private transient JLabel blockNameLabel = new JLabel();
private transient NamedBeanComboBox<Block> blockIDComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(BlockManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JCheckBox highlightBlockCheckBox = new JCheckBox(Bundle.getMessage("HighlightSelectedBlockTitle"));
private transient JLabel blockSensorNameLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BlockSensorName")));
private transient JLabel blockSensorLabel = new JLabel(Bundle.getMessage("BeanNameSensor"));
private transient NamedBeanComboBox<Sensor> blockSensorComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(SensorManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
//3rd row of radio buttons (and any associated text fields)
private transient JLabel nodesLabel = new JLabel();
private transient JRadioButton endBumperButton = new JRadioButton(Bundle.getMessage("EndBumper"));
private transient JRadioButton anchorButton = new JRadioButton(Bundle.getMessage("Anchor"));
private transient JRadioButton edgeButton = new JRadioButton(Bundle.getMessage("EdgeConnector"));
private transient JLabel labelsLabel = new JLabel();
private transient JRadioButton textLabelButton = new JRadioButton(Bundle.getMessage("TextLabel"));
private transient JTextField textLabelTextField = new JTextField(12);
private transient JRadioButton memoryButton = new JRadioButton(Bundle.getMessage("BeanNameMemory"));
private transient NamedBeanComboBox<Memory> textMemoryComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(MemoryManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JRadioButton blockContentsButton = new JRadioButton(Bundle.getMessage("BlockContentsLabel"));
private transient NamedBeanComboBox<Block> blockContentsComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(BlockManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
//4th row of radio buttons (and any associated text fields)
private transient JRadioButton multiSensorButton = new JRadioButton(Bundle.getMessage("MultiSensor") + "...");
private transient JRadioButton signalMastButton = new JRadioButton(Bundle.getMessage("SignalMastIcon"));
private transient NamedBeanComboBox<SignalMast> signalMastComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(SignalMastManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JRadioButton sensorButton = new JRadioButton(Bundle.getMessage("SensorIcon"));
private transient NamedBeanComboBox<Sensor> sensorComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(SensorManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JRadioButton signalButton = new JRadioButton(Bundle.getMessage("SignalIcon"));
private transient NamedBeanComboBox<SignalHead> signalHeadComboBox = new NamedBeanComboBox<>(
InstanceManager.getDefault(SignalHeadManager.class), null, NamedBeanComboBox.DisplayOptions.DISPLAYNAME);
private transient JRadioButton iconLabelButton = new JRadioButton(Bundle.getMessage("IconLabel"));
private transient JRadioButton shapeButton = new JRadioButton(Bundle.getMessage("LayoutShape"));
private transient JButton changeIconsButton = new JButton(Bundle.getMessage("ChangeIcons") + "...");
public transient MultiIconEditor sensorIconEditor = null;
public transient JFrame sensorFrame = null;
public transient MultiIconEditor signalIconEditor = null;
public transient JFrame signalFrame = null;
private transient MultiIconEditor iconEditor = null;
private transient JFrame iconFrame = null;
private transient MultiSensorIconFrame multiSensorFrame = null;
private transient JLabel xLabel = new JLabel("00");
private transient JLabel yLabel = new JLabel("00");
private transient JPanel zoomPanel = new JPanel();
private transient JLabel zoomLabel = new JLabel("x1");
private transient JMenu zoomMenu = new JMenu(Bundle.getMessage("MenuZoom"));
private transient JRadioButtonMenuItem zoom025Item = new JRadioButtonMenuItem("x 0.25");
private transient JRadioButtonMenuItem zoom05Item = new JRadioButtonMenuItem("x 0.5");
private transient JRadioButtonMenuItem zoom075Item = new JRadioButtonMenuItem("x 0.75");
private transient JRadioButtonMenuItem noZoomItem = new JRadioButtonMenuItem(Bundle.getMessage("NoZoom"));
private transient JRadioButtonMenuItem zoom15Item = new JRadioButtonMenuItem("x 1.5");
private transient JRadioButtonMenuItem zoom20Item = new JRadioButtonMenuItem("x 2.0");
private transient JRadioButtonMenuItem zoom30Item = new JRadioButtonMenuItem("x 3.0");
private transient JRadioButtonMenuItem zoom40Item = new JRadioButtonMenuItem("x 4.0");
private transient JRadioButtonMenuItem zoom50Item = new JRadioButtonMenuItem("x 5.0");
private transient JRadioButtonMenuItem zoom60Item = new JRadioButtonMenuItem("x 6.0");
private transient JRadioButtonMenuItem zoom70Item = new JRadioButtonMenuItem("x 7.0");
private transient JRadioButtonMenuItem zoom80Item = new JRadioButtonMenuItem("x 8.0");
private transient JPanel locationPanel = new JPanel();
//end of main panel controls
private transient boolean delayedPopupTrigger = false;
private transient Point2D currentPoint = new Point2D.Double(100.0, 100.0);
private transient Point2D dLoc = new Point2D.Double(0.0, 0.0);
private transient int toolbarHeight = 100;
private transient int toolbarWidth = 100;
//private transient int numTurnouts = 0;
private transient TrackSegment newTrack = null;
private transient boolean panelChanged = false;
//grid size in pixels
private transient int gridSize1st = 10;
// secondary grid
private transient int gridSize2nd = 10;
//size of point boxes
protected static final double SIZE = 3.0;
protected static final double SIZE2 = SIZE * 2.; //must be twice SIZE
protected Color turnoutCircleColor = Color.black; //matches earlier versions
protected Color turnoutCircleThrownColor = Color.black;
protected boolean turnoutFillControlCircles = false;
protected int turnoutCircleSize = 4; //matches earlier versions
//use turnoutCircleSize when you need an int and these when you need a double
//note: these only change when setTurnoutCircleSize is called
//using these avoids having to call getTurnoutCircleSize() and
//the multiply (x2) and the int -> double conversion overhead
private transient double circleRadius = SIZE * getTurnoutCircleSize();
private transient double circleDiameter = 2.0 * circleRadius;
//selection variables
private transient boolean selectionActive = false;
private transient double selectionX = 0.0;
private transient double selectionY = 0.0;
private transient double selectionWidth = 0.0;
private transient double selectionHeight = 0.0;
//Option menu items
private transient JCheckBoxMenuItem editModeCheckBoxMenuItem = null;
private transient JRadioButtonMenuItem toolBarSideTopButton = null;
private transient JRadioButtonMenuItem toolBarSideLeftButton = null;
private transient JRadioButtonMenuItem toolBarSideBottomButton = null;
private transient JRadioButtonMenuItem toolBarSideRightButton = null;
private transient JRadioButtonMenuItem toolBarSideFloatButton = null;
private transient JMenu toolBarFontSizeMenu = new JMenu(Bundle.getMessage("FontSize"));
private transient JCheckBoxMenuItem wideToolBarCheckBoxMenuItem = new JCheckBoxMenuItem(Bundle.getMessage("ToolBarWide"));
private transient JMenu dropDownListsDisplayOrderMenu = new JMenu(Bundle.getMessage("DropDownListsDisplayOrder"));
private transient JCheckBoxMenuItem positionableCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem controlCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem animationCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem showHelpCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem showGridCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem autoAssignBlocksCheckBoxMenuItem = null;
private transient JMenu scrollMenu = null;
private transient JRadioButtonMenuItem scrollBothMenuItem = null;
private transient JRadioButtonMenuItem scrollNoneMenuItem = null;
private transient JRadioButtonMenuItem scrollHorizontalMenuItem = null;
private transient JRadioButtonMenuItem scrollVerticalMenuItem = null;
private transient JMenu tooltipMenu = null;
private transient JRadioButtonMenuItem tooltipAlwaysMenuItem = null;
private transient JRadioButtonMenuItem tooltipNoneMenuItem = null;
private transient JRadioButtonMenuItem tooltipInEditMenuItem = null;
private transient JRadioButtonMenuItem tooltipNotInEditMenuItem = null;
private transient JCheckBoxMenuItem snapToGridOnAddCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem snapToGridOnMoveCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem antialiasingOnCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem turnoutCirclesOnCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem turnoutDrawUnselectedLegCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem turnoutFillControlCirclesCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem hideTrackSegmentConstructionLinesCheckBoxMenuItem = null;
private transient JCheckBoxMenuItem useDirectTurnoutControlCheckBoxMenuItem = null;
private transient ButtonGroup turnoutCircleSizeButtonGroup = null;
private transient boolean turnoutDrawUnselectedLeg = true;
private transient boolean autoAssignBlocks = false;
//Tools menu items
private transient JMenuItem undoTranslateSelectionMenuItem = new JMenuItem(Bundle.getMessage("UndoTranslateSelection"));
private transient JMenuItem assignBlockToSelectionMenuItem = new JMenuItem(Bundle.getMessage("AssignBlockToSelectionTitle") + "...");
//Selected point information
private transient Point2D startDelta = new Point2D.Double(0.0, 0.0); //starting delta coordinates
protected transient Object selectedObject = null; //selected object, null if nothing selected
protected transient Object prevSelectedObject = null; //previous selected object, for undo
private transient int selectedHitPointType = 0; //hit point type within the selected object
private transient LayoutTrack foundTrack = null; //found object, null if nothing found
private transient Point2D foundLocation = new Point2D.Double(0.0, 0.0); //location of found object
private transient int foundHitPointType = 0; //connection type within the found object
@SuppressWarnings("unused")
private transient boolean foundNeedsConnect = false; //true if found point needs a connection
private transient LayoutTrack beginTrack = null; //begin track segment connection object, null if
//none
private transient Point2D beginLocation = new Point2D.Double(0.0, 0.0); //location of begin object
private transient int beginHitPointType = LayoutTrack.NONE; //connection type within begin connection object
private transient Point2D currentLocation = new Point2D.Double(0.0, 0.0); //current location
//Lists of items that describe the Layout, and allow it to be drawn
//Each of the items must be saved to disk over sessions
public transient List<AnalogClock2Display> clocks = new ArrayList<>(); //fast clocks
public transient List<LocoIcon> markerImage = new ArrayList<>(); //marker images
public transient List<MultiSensorIcon> multiSensors = new ArrayList<>(); //multi-sensor images
public transient List<PositionableLabel> backgroundImage = new ArrayList<>(); //background images
public transient List<PositionableLabel> labelImage = new ArrayList<>(); //positionable label images
public transient List<SensorIcon> sensorImage = new ArrayList<>(); //sensor images
public transient List<SignalHeadIcon> signalHeadImage = new ArrayList<>(); //signal head images
private transient List<LayoutTrack> layoutTrackList = new ArrayList<>(); // LayoutTrack list
// PositionableLabel's
public transient List<BlockContentsIcon> blockContentsLabelList = new ArrayList<>(); //BlockContentsIcon Label List
public transient List<MemoryIcon> memoryLabelList = new ArrayList<>(); //Memory Label List
public transient List<SensorIcon> sensorList = new ArrayList<>(); //Sensor Icons
public transient List<SignalHeadIcon> signalList = new ArrayList<>(); //Signal Head Icons
public transient List<SignalMastIcon> signalMastList = new ArrayList<>(); //Signal Mast Icons
private transient List<LayoutShape> layoutShapes = new ArrayList<>(); // LayoutShap list
// counts used to determine unique internal names
private transient int numAnchors = 0;
private transient int numEndBumpers = 0;
private transient int numEdgeConnectors = 0;
private transient int numTrackSegments = 0;
private transient int numLevelXings = 0;
private transient int numLayoutSlips = 0;
private transient int numLayoutTurnouts = 0;
private transient int numLayoutTurntables = 0;
private transient int numShapes = 0;
public transient LayoutEditorFindItems finder = new LayoutEditorFindItems(this);
@Nonnull
public LayoutEditorFindItems getFinder() {
return finder;
}
//persistent instance variables - saved to disk with Save Panel
private transient int upperLeftX = 0; // Note: These are _WINDOW_ upper left x & y
private transient int upperLeftY = 0; // (not panel)
private transient int windowWidth = 0;
private transient int windowHeight = 0;
private transient int panelWidth = 0;
private transient int panelHeight = 0;
private transient float mainlineTrackWidth = 4.0F;
private transient float sidelineTrackWidth = 2.0F;
private transient Color mainlineTrackColor = Color.DARK_GRAY ;
private transient Color sidelineTrackColor = Color.DARK_GRAY ;
private transient Color defaultTrackColor = Color.DARK_GRAY;
private transient Color defaultOccupiedTrackColor = Color.red;
private transient Color defaultAlternativeTrackColor = Color.white;
private transient Color defaultBackgroundColor = Color.lightGray;
private transient Color defaultTextColor = Color.black;
private transient String layoutName = "";
private transient double xScale = 1.0;
private transient double yScale = 1.0;
private transient boolean animatingLayout = true;
private transient boolean showHelpBar = true;
private transient boolean drawGrid = true;
private transient boolean snapToGridOnAdd = false;
private transient boolean snapToGridOnMove = false;
private transient boolean snapToGridInvert = false;
private transient boolean antialiasingOn = false;
private transient boolean highlightSelectedBlockFlag = false;
private transient boolean turnoutCirclesWithoutEditMode = false;
private transient boolean tooltipsWithoutEditMode = false;
private transient boolean tooltipsInEditMode = true;
//turnout size parameters - saved with panel
private transient double turnoutBX = LayoutTurnout.turnoutBXDefault; //RH, LH, WYE
private transient double turnoutCX = LayoutTurnout.turnoutCXDefault;
private transient double turnoutWid = LayoutTurnout.turnoutWidDefault;
private transient double xOverLong = LayoutTurnout.xOverLongDefault; //DOUBLE_XOVER, RH_XOVER, LH_XOVER
private transient double xOverHWid = LayoutTurnout.xOverHWidDefault;
private transient double xOverShort = LayoutTurnout.xOverShortDefault;
private transient boolean useDirectTurnoutControl = false; //Uses Left click for closing points, Right click for throwing.
//saved state of options when panel was loaded or created
private transient boolean savedEditMode = true;
private transient boolean savedPositionable = true;
private transient boolean savedControlLayout = true;
private transient boolean savedAnimatingLayout = true;
private transient boolean savedShowHelpBar = true;
//zoom
private transient double minZoom = 0.25;
private transient double maxZoom = 8.0;
//Special sub group for color treatment when active
JPanel blockPropertiesPanel = null;
//A hash to store string -> KeyEvent constants, used to set keyboard shortcuts per locale
protected transient HashMap<String, Integer> stringsToVTCodes = new HashMap<>();
//Antialiasing rendering
private transient static final RenderingHints antialiasing = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
private enum ToolBarSide {
eTOP("top"),
eLEFT("left"),
eBOTTOM("bottom"),
eRIGHT("right"),
eFLOAT("float");
private final transient String name;
private transient static final Map<String, ToolBarSide> ENUM_MAP;
ToolBarSide(String name) {
this.name = name;
}
//Build an immutable map of String name to enum pairs.
static {
Map<String, ToolBarSide> map = new ConcurrentHashMap<>();
for (ToolBarSide instance : ToolBarSide.values()) {
map.put(instance.getName(), instance);
}
ENUM_MAP = Collections.unmodifiableMap(map);
}
public static ToolBarSide getName(@Nullable String name) {
return ENUM_MAP.get(name);
}
public String getName() {
return name;
}
}
private transient ToolBarSide toolBarSide = ToolBarSide.eTOP;
private transient boolean toolBarIsWide = true;
public LayoutEditor() {
this("My Layout");
}
public LayoutEditor(@Nonnull String name) {
super(name);
setSaveSize(true);
layoutName = name;
editorUseOldLocSize = InstanceManager.getDefault(apps.gui.GuiLafPreferencesManager.class).isEditorUseOldLocSize();
//initialise keycode map
initStringsToVTCodes();
//initialize menu bar
JMenuBar menuBar = new JMenuBar();
//set up File menu
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
fileMenu.setMnemonic(stringsToVTCodes.get(Bundle.getMessage("MenuFileMnemonic")));
menuBar.add(fileMenu);
StoreXmlUserAction store = new StoreXmlUserAction(Bundle.getMessage("MenuItemStore"));
int primary_modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
store.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
stringsToVTCodes.get(Bundle.getMessage("MenuItemStoreAccelerator")), primary_modifier));
fileMenu.add(store);
fileMenu.addSeparator();
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("DeletePanel"));
fileMenu.add(deleteItem);
deleteItem.addActionListener((ActionEvent event) -> {
if (deletePanel()) {
dispose();
}
});
setJMenuBar(menuBar);
//setup Options menu
setupOptionMenu(menuBar);
//setup Tools menu
setupToolsMenu(menuBar);
//setup Zoom menu
setupZoomMenu(menuBar);
//setup marker menu
setupMarkerMenu(menuBar);
//Setup Dispatcher window
setupDispatcherMenu(menuBar);
//setup Help menu
addHelpMenu("package.jmri.jmrit.display.LayoutEditor", true);
//setup group for radio buttons selecting items to add and line style
itemGroup = new ButtonGroup();
itemGroup.add(turnoutRHButton);
itemGroup.add(turnoutLHButton);
itemGroup.add(turnoutWYEButton);
itemGroup.add(doubleXoverButton);
itemGroup.add(rhXoverButton);
itemGroup.add(lhXoverButton);
itemGroup.add(levelXingButton);
itemGroup.add(layoutSingleSlipButton);
itemGroup.add(layoutDoubleSlipButton);
itemGroup.add(endBumperButton);
itemGroup.add(anchorButton);
itemGroup.add(edgeButton);
itemGroup.add(trackButton);
itemGroup.add(multiSensorButton);
itemGroup.add(sensorButton);
itemGroup.add(signalButton);
itemGroup.add(signalMastButton);
itemGroup.add(textLabelButton);
itemGroup.add(memoryButton);
itemGroup.add(blockContentsButton);
itemGroup.add(iconLabelButton);
itemGroup.add(shapeButton);
//This is used to enable/disable property controls depending on which (radio) button is selected
ActionListener selectionListAction = (ActionEvent event) -> {
//turnout properties
boolean e = (turnoutRHButton.isSelected()
|| turnoutLHButton.isSelected()
|| turnoutWYEButton.isSelected()
|| doubleXoverButton.isSelected()
|| rhXoverButton.isSelected()
|| lhXoverButton.isSelected()
|| layoutSingleSlipButton.isSelected()
|| layoutDoubleSlipButton.isSelected());
log.debug("turnoutPropertiesPanel is {}", e ? "enabled" : "disabled");
turnoutNamePanel.setEnabled(e);
for (Component i : turnoutNamePanel.getComponents()) {
i.setEnabled(e);
}
rotationPanel.setEnabled(e);
for (Component i : rotationPanel.getComponents()) {
i.setEnabled(e);
}
//second turnout property
e = (layoutSingleSlipButton.isSelected() || layoutDoubleSlipButton.isSelected());
log.debug("extraTurnoutPanel is {}", e ? "enabled" : "disabled");
for (Component i : extraTurnoutPanel.getComponents()) {
i.setEnabled(e);
}
//track Segment properties
e = trackButton.isSelected();
log.debug("trackSegmentPropertiesPanel is {}", e ? "enabled" : "disabled");
for (Component i : trackSegmentPropertiesPanel.getComponents()) {
i.setEnabled(e);
}
//block properties
e = (turnoutRHButton.isSelected()
|| turnoutLHButton.isSelected()
|| turnoutWYEButton.isSelected()
|| doubleXoverButton.isSelected()
|| rhXoverButton.isSelected()
|| lhXoverButton.isSelected()
|| layoutSingleSlipButton.isSelected()
|| layoutDoubleSlipButton.isSelected()
|| levelXingButton.isSelected()
|| trackButton.isSelected());
log.debug("blockPanel is {}", e ? "enabled" : "disabled");
if (blockPropertiesPanel != null) {
for (Component i : blockPropertiesPanel.getComponents()) {
i.setEnabled(e);
}
if (e) {
blockPropertiesPanel.setBackground(Color.lightGray);
} else {
blockPropertiesPanel.setBackground(new Color(238, 238, 238));
}
} else {
blockNameLabel.setEnabled(e);
blockIDComboBox.setEnabled(e);
blockSensorNameLabel.setEnabled(e);
blockSensorLabel.setEnabled(e);
blockSensorComboBox.setEnabled(e);
}
//enable/disable text label, memory & block contents text fields
textLabelTextField.setEnabled(textLabelButton.isSelected());
textMemoryComboBox.setEnabled(memoryButton.isSelected());
blockContentsComboBox.setEnabled(blockContentsButton.isSelected());
//enable/disable signal mast, sensor & signal head text fields
signalMastComboBox.setEnabled(signalMastButton.isSelected());
sensorComboBox.setEnabled(sensorButton.isSelected());
signalHeadComboBox.setEnabled(signalButton.isSelected());
//changeIconsButton
e = (sensorButton.isSelected()
|| signalButton.isSelected()
|| iconLabelButton.isSelected());
log.debug("changeIconsButton is {}", e ? "enabled" : "disabled");
changeIconsButton.setEnabled(e);
};
turnoutRHButton.addActionListener(selectionListAction);
turnoutLHButton.addActionListener(selectionListAction);
turnoutWYEButton.addActionListener(selectionListAction);
doubleXoverButton.addActionListener(selectionListAction);
rhXoverButton.addActionListener(selectionListAction);
lhXoverButton.addActionListener(selectionListAction);
levelXingButton.addActionListener(selectionListAction);
layoutSingleSlipButton.addActionListener(selectionListAction);
layoutDoubleSlipButton.addActionListener(selectionListAction);
endBumperButton.addActionListener(selectionListAction);
anchorButton.addActionListener(selectionListAction);
edgeButton.addActionListener(selectionListAction);
trackButton.addActionListener(selectionListAction);
multiSensorButton.addActionListener(selectionListAction);
sensorButton.addActionListener(selectionListAction);
signalButton.addActionListener(selectionListAction);
signalMastButton.addActionListener(selectionListAction);
textLabelButton.addActionListener(selectionListAction);
memoryButton.addActionListener(selectionListAction);
blockContentsButton.addActionListener(selectionListAction);
iconLabelButton.addActionListener(selectionListAction);
shapeButton.addActionListener(selectionListAction);
//first row of edit tool bar items
//turnout items
turnoutRHButton.setSelected(true);
turnoutRHButton.setToolTipText(Bundle.getMessage("RHToolTip"));
turnoutLHButton.setToolTipText(Bundle.getMessage("LHToolTip"));
turnoutWYEButton.setToolTipText(Bundle.getMessage("WYEToolTip"));
doubleXoverButton.setToolTipText(Bundle.getMessage("DoubleCrossoverToolTip"));
rhXoverButton.setToolTipText(Bundle.getMessage("RHCrossoverToolTip"));
lhXoverButton.setToolTipText(Bundle.getMessage("LHCrossoverToolTip"));
layoutSingleSlipButton.setToolTipText(Bundle.getMessage("SingleSlipToolTip"));
layoutDoubleSlipButton.setToolTipText(Bundle.getMessage("DoubleSlipToolTip"));
String turnoutNameString = Bundle.getMessage("Name");
JLabel turnoutNameLabel = new JLabel(turnoutNameString);
turnoutNamePanel.add(turnoutNameLabel);
setupComboBox(turnoutNameComboBox, false, true);
turnoutNameComboBox.setToolTipText(Bundle.getMessage("TurnoutNameToolTip"));
turnoutNamePanel.add(turnoutNameComboBox);
// disable turnouts that are already in use
turnoutNameComboBox.addPopupMenuListener(newTurnoutComboBoxPopupMenuListener(turnoutNameComboBox));
// turnoutNameComboBox.setEnabledColor(Color.green.darker().darker());
// turnoutNameComboBox.setDisabledColor(Color.red);
setupComboBox(extraTurnoutNameComboBox, false, true);
extraTurnoutNameComboBox.setToolTipText(Bundle.getMessage("SecondTurnoutNameToolTip"));
extraTurnoutNameComboBox.addPopupMenuListener(newTurnoutComboBoxPopupMenuListener(turnoutNameComboBox));
// extraTurnoutNameComboBox.setEnabledColor(Color.green.darker().darker());
// extraTurnoutNameComboBox.setDisabledColor(Color.red);
//this is enabled/disabled via selectionListAction above
JLabel extraTurnoutLabel = new JLabel(Bundle.getMessage("SecondName"));
extraTurnoutLabel.setEnabled(false);
extraTurnoutPanel.add(extraTurnoutLabel);
extraTurnoutPanel.add(extraTurnoutNameComboBox);
extraTurnoutPanel.setEnabled(false);
String[] angleStrings = {"-180", "-135", "-90", "-45", "0", "+45", "+90", "+135", "+180"};
rotationComboBox = new JComboBox<>(angleStrings);
rotationComboBox.setEditable(true);
rotationComboBox.setSelectedIndex(4);
rotationComboBox.setMaximumRowCount(9);
rotationComboBox.setToolTipText(Bundle.getMessage("RotationToolTip"));
JLabel rotationLabel = new JLabel(Bundle.getMessage("Rotation"));
rotationPanel.add(rotationLabel);
rotationPanel.add(rotationComboBox);
zoomPanel.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("ZoomLabel"))));
zoomPanel.add(zoomLabel);
Dimension coordSize = xLabel.getPreferredSize();
coordSize.width *= 2;
xLabel.setPreferredSize(coordSize);
yLabel.setPreferredSize(coordSize);
locationPanel.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("Location"))));
locationPanel.add(new JLabel("{x:"));
locationPanel.add(xLabel);
locationPanel.add(new JLabel(", y:"));
locationPanel.add(yLabel);
locationPanel.add(new JLabel("} "));
//second row of edit tool bar items
levelXingButton.setToolTipText(Bundle.getMessage("LevelCrossingToolTip"));
trackButton.setToolTipText(Bundle.getMessage("TrackSegmentToolTip"));
//this is enabled/disabled via selectionListAction above
trackSegmentPropertiesPanel.add(mainlineTrack);
mainlineTrack.setSelected(false);
mainlineTrack.setEnabled(false);
mainlineTrack.setToolTipText(Bundle.getMessage("MainlineCheckBoxTip"));
trackSegmentPropertiesPanel.add(dashedLine);
dashedLine.setSelected(false);
dashedLine.setEnabled(false);
dashedLine.setToolTipText(Bundle.getMessage("DashedCheckBoxTip"));
//the blockPanel is enabled/disabled via selectionListAction above
setupComboBox(blockIDComboBox, false, true);
blockIDComboBox.setToolTipText(Bundle.getMessage("BlockIDToolTip"));
//change the block name
blockIDComboBox.addActionListener((ActionEvent event) -> {
//use the "Extra" color to highlight the selected block
if (highlightSelectedBlockFlag) {
highlightBlockInComboBox(blockIDComboBox);
}
String newName = blockIDComboBox.getSelectedItemDisplayName();
LayoutBlock b = InstanceManager.getDefault(LayoutBlockManager.class).getByUserName(newName);
if (b != null) {
//if there is an occupancy sensor assigned already
String sensorName = b.getOccupancySensorName();
if (!sensorName.isEmpty()) {
//update the block sensor ComboBox
blockSensorComboBox.setSelectedItem(b.getOccupancySensor());
} else {
blockSensorComboBox.setSelectedItem(null);
}
}
});
setupComboBox(blockSensorComboBox, false, true);
blockSensorComboBox.setToolTipText(Bundle.getMessage("OccupancySensorToolTip"));
//third row of edit tool bar items
endBumperButton.setToolTipText(Bundle.getMessage("EndBumperToolTip"));
anchorButton.setToolTipText(Bundle.getMessage("AnchorToolTip"));
edgeButton.setToolTipText(Bundle.getMessage("EdgeConnectorToolTip"));
textLabelButton.setToolTipText(Bundle.getMessage("TextLabelToolTip"));
textLabelTextField.setToolTipText(Bundle.getMessage("TextToolTip"));
textLabelTextField.setEnabled(false);
memoryButton.setToolTipText(Bundle.getMessage("MemoryButtonToolTip", Bundle.getMessage("Memory")));
setupComboBox(textMemoryComboBox, true, false);
textMemoryComboBox.setToolTipText(Bundle.getMessage("MemoryToolTip"));
blockContentsButton.setToolTipText(Bundle.getMessage("BlockContentsButtonToolTip"));
setupComboBox(blockContentsComboBox, true, false);
blockContentsComboBox.setToolTipText(Bundle.getMessage("BlockContentsButtonToolTip"));
blockContentsComboBox.addActionListener((ActionEvent event) -> {
//use the "Extra" color to highlight the selected block
if (highlightSelectedBlockFlag) {
highlightBlockInComboBox(blockContentsComboBox);
}
});
//fourth row of edit tool bar items
//multi sensor...
multiSensorButton.setToolTipText(Bundle.getMessage("MultiSensorToolTip"));
//Signal Mast & text
signalMastButton.setToolTipText(Bundle.getMessage("SignalMastButtonToolTip"));
setupComboBox(signalMastComboBox, true, false);
//sensor icon & text
sensorButton.setToolTipText(Bundle.getMessage("SensorButtonToolTip"));
setupComboBox(sensorComboBox, true, false);
sensorComboBox.setToolTipText(Bundle.getMessage("SensorIconToolTip"));
sensorIconEditor = new MultiIconEditor(4);
sensorIconEditor.setIcon(0, Bundle.getMessage("MakeLabel", Bundle.getMessage("SensorStateActive")),
"resources/icons/smallschematics/tracksegments/circuit-occupied.gif");
sensorIconEditor.setIcon(1, Bundle.getMessage("MakeLabel", Bundle.getMessage("SensorStateInactive")),
"resources/icons/smallschematics/tracksegments/circuit-empty.gif");
sensorIconEditor.setIcon(2, Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanStateInconsistent")),
"resources/icons/smallschematics/tracksegments/circuit-error.gif");
sensorIconEditor.setIcon(3, Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanStateUnknown")),
"resources/icons/smallschematics/tracksegments/circuit-error.gif");
sensorIconEditor.complete();
//Signal icon & text
signalButton.setToolTipText(Bundle.getMessage("SignalButtonToolTip"));
setupComboBox(signalHeadComboBox, true, false);
signalHeadComboBox.setToolTipText(Bundle.getMessage("SignalIconToolTip"));
signalIconEditor = new MultiIconEditor(10);
signalIconEditor.setIcon(0, "Red:", "resources/icons/smallschematics/searchlights/left-red-short.gif");
signalIconEditor.setIcon(1, "Flash red:", "resources/icons/smallschematics/searchlights/left-flashred-short.gif");
signalIconEditor.setIcon(2, "Yellow:", "resources/icons/smallschematics/searchlights/left-yellow-short.gif");
signalIconEditor.setIcon(3,
"Flash yellow:",
"resources/icons/smallschematics/searchlights/left-flashyellow-short.gif");
signalIconEditor.setIcon(4, "Green:", "resources/icons/smallschematics/searchlights/left-green-short.gif");
signalIconEditor.setIcon(5, "Flash green:",
"resources/icons/smallschematics/searchlights/left-flashgreen-short.gif");
signalIconEditor.setIcon(6, "Dark:", "resources/icons/smallschematics/searchlights/left-dark-short.gif");
signalIconEditor.setIcon(7, "Held:", "resources/icons/smallschematics/searchlights/left-held-short.gif");
signalIconEditor.setIcon(8,
"Lunar",
"resources/icons/smallschematics/searchlights/left-lunar-short-marker.gif");
signalIconEditor.setIcon(9,
"Flash Lunar",
"resources/icons/smallschematics/searchlights/left-flashlunar-short-marker.gif");
signalIconEditor.complete();
sensorFrame = new JFrame(Bundle.getMessage("EditSensorIcons"));
sensorFrame.getContentPane().add(new JLabel(Bundle.getMessage("IconChangeInfo")), BorderLayout.NORTH);
sensorFrame.getContentPane().add(sensorIconEditor);
sensorFrame.pack();
signalFrame = new JFrame(Bundle.getMessage("EditSignalIcons"));
signalFrame.getContentPane().add(new JLabel(Bundle.getMessage("IconChangeInfo")), BorderLayout.NORTH);
// no spaces around Label as that breaks html formatting
signalFrame.getContentPane().add(signalIconEditor);
signalFrame.pack();
signalFrame.setVisible(false);
//icon label
iconLabelButton.setToolTipText(Bundle.getMessage("IconLabelToolTip"));
shapeButton.setToolTipText(Bundle.getMessage("LayoutShapeToolTip"));
//change icons...
//this is enabled/disabled via selectionListAction above
changeIconsButton.addActionListener((ActionEvent event) -> {
if (sensorButton.isSelected()) {
sensorFrame.setVisible(true);
} else if (signalButton.isSelected()) {
signalFrame.setVisible(true);
} else if (iconLabelButton.isSelected()) {
iconFrame.setVisible(true);
} else {
//explain to the user why nothing happens
JOptionPane.showMessageDialog(null, Bundle.getMessage("ChangeIconNotApplied"),
Bundle.getMessage("ChangeIcons"), JOptionPane.INFORMATION_MESSAGE);
}
});
changeIconsButton.setToolTipText(Bundle.getMessage("ChangeIconToolTip"));
changeIconsButton.setEnabled(false);
//??
iconEditor = new MultiIconEditor(1);
iconEditor.setIcon(0, "", "resources/icons/smallschematics/tracksegments/block.gif");
iconEditor.complete();
iconFrame = new JFrame(Bundle.getMessage("EditIcon"));
iconFrame.getContentPane().add(iconEditor);
iconFrame.pack();
super.setDefaultToolTip(new ToolTip(null, 0, 0, new Font("SansSerif", Font.PLAIN, 12),
Color.black, new Color(215, 225, 255), Color.black));
//setup help bar
helpBar.setLayout(new BoxLayout(helpBar, BoxLayout.PAGE_AXIS));
JTextArea helpTextArea1 = new JTextArea(Bundle.getMessage("Help1"));
helpBar.add(helpTextArea1);
JTextArea helpTextArea2 = new JTextArea(Bundle.getMessage("Help2"));
helpBar.add(helpTextArea2);
String helpText3 = "";
switch (SystemType.getType()) {
case SystemType.MACOSX: {
helpText3 = Bundle.getMessage("Help3Mac");
break;
}
case SystemType.WINDOWS:
case SystemType.LINUX: {
helpText3 = Bundle.getMessage("Help3Win");
break;
}
default:
helpText3 = Bundle.getMessage("Help3");
}
JTextArea helpTextArea3 = new JTextArea(helpText3);
helpBar.add(helpTextArea3);
//set to full screen
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
windowWidth = screenDim.width - 20;
windowHeight = screenDim.height - 120;
//Let Editor make target, and use this frame
super.setTargetPanel(null, null);
super.setTargetPanelSize(windowWidth, windowHeight);
setSize(screenDim.width, screenDim.height);
setupToolBar();
//register the resulting panel for later configuration
ConfigureManager cm = InstanceManager.getNullableDefault(ConfigureManager.class);
if (cm != null) {
cm.registerUser(this);
}
//confirm that panel hasn't already been loaded
if (InstanceManager.getDefault(PanelMenu.class).isPanelNameUsed(name)) {
log.warn("File contains a panel with the same name ({}) as an existing panel", name);
}
setFocusable(true);
addKeyListener(this);
resetDirty();
//establish link to LayoutEditor Tools