001package jmri.jmrit.display.layoutEditor.LayoutEditorDialogs; 002 003import java.awt.Color; 004import java.awt.event.ActionEvent; 005import java.util.ArrayList; 006import java.util.List; 007 008import javax.swing.*; 009import javax.swing.event.ChangeEvent; 010 011import jmri.jmrit.display.layoutEditor.LayoutEditor; 012import jmri.jmrit.display.layoutEditor.LayoutTrackDrawingOptions; 013import jmri.util.swing.JmriColorChooser; 014 015import org.slf4j.Logger; 016import org.slf4j.LoggerFactory; 017 018/******************************************************************************* 019 * Handle changing layout editor drawing options. 020 * 021 * since 4.15.6 blockDefaultColor, blockOccupiedColor and blockAlternativeColor added here. 022 * Color settings blockDefaultColor, blockOccupiedColor and blockAlternativeColor respects the original solution. 023 * It would be useful to drop the original defaultTrackColor, defaultOccupiedTrackColor 024 * and defaultAlternativeTrackColor variables In {@link LayoutEditor} and use only those of 025 * {@link LayoutTrackDrawingOptions}. 026 * 027 * @author George Warner Copyright (c) 2017-2018 028 */ 029public class LayoutTrackDrawingOptionsDialog extends JDialog { 030 031 private final LayoutEditor layoutEditor; 032 private final LayoutTrackDrawingOptions leLTDOptions; 033 private LayoutTrackDrawingOptions ltdOptions = null; 034 035 private final String classicPresetName = Bundle.getMessage("ClassicPresetName"); 036 private final String draftingPresetName = Bundle.getMessage("DraftingPresetName"); 037 private final String realisticPresetName = Bundle.getMessage("RealisticPresetName"); 038 private final String realisticOhPresetName = Bundle.getMessage("RealisticOhPresetName"); 039 private final String british70sPresetName = Bundle.getMessage("British70sPresetName"); 040 private final String csdazd71PresetName = Bundle.getMessage("CsdAzd71PresetName"); 041 private final String customPresetName = Bundle.getMessage("CustomPresetName"); 042 043 private final List<LayoutTrackDrawingOptions> ltdoList = new ArrayList<>(); 044 045 /** 046 * Creates new form LayoutTrackDrawingOptionsDialog. 047 * @param layoutEditor the main layout editor panel. 048 * @param modal true if frame should be modal, else false. 049 * @param ltdOptions the layout track drawing options. 050 */ 051 public LayoutTrackDrawingOptionsDialog(LayoutEditor layoutEditor, boolean modal, 052 LayoutTrackDrawingOptions ltdOptions) { 053 super(layoutEditor, modal); 054 055 this.layoutEditor = layoutEditor; 056 this.leLTDOptions = ltdOptions; 057 this.ltdOptions = new LayoutTrackDrawingOptions(ltdOptions); 058 059 initComponents(); 060 this.setTitle(Bundle.getMessage("SetTrackDrawingOptions")); 061 setLocationRelativeTo(layoutEditor); 062 definePresets(); 063 pack(); 064 } 065 066 /** 067 * This method is called from within the constructor to initialize the form. 068 * WARNING: Do NOT modify this code. The content of this method is always 069 * regenerated by the Form Editor. 070 */ 071 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 072 private void initComponents() { 073 java.awt.GridBagConstraints gridBagConstraints; 074 075 optionsPanel = new javax.swing.JPanel(); 076 optionLabel = new javax.swing.JLabel(); 077 078 javax.swing.JLabel blockDefaultColorLabel = new javax.swing.JLabel(); 079 blockDefaultColorButton = new javax.swing.JButton(); 080 javax.swing.JLabel blockOccupiedColorLabel = new javax.swing.JLabel(); 081 blockOccupiedColorButton = new javax.swing.JButton(); 082 javax.swing.JLabel blockAlternativeColorLabel = new javax.swing.JLabel(); 083 blockAlternativeColorButton = new javax.swing.JButton(); 084 085 mainlineLabel = new javax.swing.JLabel(); 086 railCountLabel = new javax.swing.JLabel(); 087 mainRailCountSpinner = new javax.swing.JSpinner(); 088 sideRailCountSpinner = new javax.swing.JSpinner(); 089 railWidthLabel = new javax.swing.JLabel(); 090 mainRailWidthSpinner = new javax.swing.JSpinner(); 091 sideRailWidthSpinner = new javax.swing.JSpinner(); 092 railGapLabel = new javax.swing.JLabel(); 093 sideRailGapSpinner = new javax.swing.JSpinner(); 094 mainRailGapSpinner = new javax.swing.JSpinner(); 095 javax.swing.JLabel railColorLabel = new javax.swing.JLabel(); 096 mainRailColorButton = new javax.swing.JButton(); 097 sideRailColorButton = new javax.swing.JButton(); 098 blockLineWidthLabel = new javax.swing.JLabel(); 099 mainBlockLineWidthSpinner = new javax.swing.JSpinner(); 100 sideBlockLineWidthSpinner = new javax.swing.JSpinner(); 101 ballastWidthLabel = new javax.swing.JLabel(); 102 mainBallastWidthSpinner = new javax.swing.JSpinner(); 103 sideBallastWidthSpinner = new javax.swing.JSpinner(); 104 javax.swing.JLabel ballastColorLabel = new javax.swing.JLabel(); 105 mainBallastColorButton = new javax.swing.JButton(); 106 sideBallastColorButton = new javax.swing.JButton(); 107 tieLengthLabel = new javax.swing.JLabel(); 108 mainTieLengthSpinner = new javax.swing.JSpinner(); 109 sideTieLengthSpinner = new javax.swing.JSpinner(); 110 tieWidthLabel = new javax.swing.JLabel(); 111 mainTieWidthSpinner = new javax.swing.JSpinner(); 112 sideTieWidthSpinner = new javax.swing.JSpinner(); 113 tieGapLabel = new javax.swing.JLabel(); 114 mainTieGapSpinner = new javax.swing.JSpinner(); 115 sideTieGapSpinner = new javax.swing.JSpinner(); 116 javax.swing.JLabel tieColorLabel = new javax.swing.JLabel(); 117 mainTieColorButton = new javax.swing.JButton(); 118 sideTieColorButton = new javax.swing.JButton(); 119 sidelineLabel = new javax.swing.JLabel(); 120 blockLineDashPercentageX10Label = new javax.swing.JLabel(); 121 mainBlockLineDashPercentageX10Spinner = new javax.swing.JSpinner(); 122 sideBlockLineDashPercentageX10Spinner = new javax.swing.JSpinner(); 123 jPanelButtons = new javax.swing.JPanel(); 124 presetsLabel = new javax.swing.JLabel(); 125 presetsComboBox = new javax.swing.JComboBox<>(); 126 applyButton = new javax.swing.JButton(); 127 cancelButton = new javax.swing.JButton(); 128 okButton = new javax.swing.JButton(); 129 130 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 131 setTitle("SetTrackDrawingOptions"); 132 setSize(new java.awt.Dimension(512, 329)); 133 134 optionsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(ltdOptions.getName())); 135 java.awt.GridBagLayout optionsPanelLayout = new java.awt.GridBagLayout(); 136 optionsPanelLayout.columnWidths = new int[] {0, 5, 0, 5, 0}; 137 optionsPanelLayout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; 138 optionsPanel.setLayout(optionsPanelLayout); 139 140 // 0 ------------------------------------------------------------------- 141 optionLabel.setFont(optionLabel.getFont().deriveFont(optionLabel.getFont().getStyle() | java.awt.Font.BOLD)); 142 optionLabel.setText(Bundle.getMessage("OptionLabelText")); 143 optionLabel.setToolTipText(Bundle.getMessage("OptionToolTip")); 144 gridBagConstraints = new java.awt.GridBagConstraints(); 145 gridBagConstraints.gridx = 0; 146 gridBagConstraints.gridy = 0; 147 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 149 gridBagConstraints.weightx = 100.0; 150 optionsPanel.add(optionLabel, gridBagConstraints); 151 152 mainlineLabel.setFont(mainlineLabel.getFont().deriveFont(mainlineLabel.getFont().getStyle() | java.awt.Font.BOLD)); 153 mainlineLabel.setText(Bundle.getMessage("MainlineLabelText")); 154 mainlineLabel.setToolTipText(Bundle.getMessage("MainlineColumnToolTip")); 155 gridBagConstraints = new java.awt.GridBagConstraints(); 156 gridBagConstraints.gridx = 2; 157 gridBagConstraints.gridy = 0; 158 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 159 gridBagConstraints.weightx = 30.0; 160 optionsPanel.add(mainlineLabel, gridBagConstraints); 161 162 sidelineLabel.setFont(sidelineLabel.getFont().deriveFont(sidelineLabel.getFont().getStyle() | java.awt.Font.BOLD)); 163 sidelineLabel.setText(Bundle.getMessage("SidelineLabelText")); 164 sidelineLabel.setToolTipText(Bundle.getMessage("SidelineColumnToolTip")); 165 gridBagConstraints = new java.awt.GridBagConstraints(); 166 gridBagConstraints.gridx = 4; 167 gridBagConstraints.gridy = 0; 168 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 169 gridBagConstraints.weightx = 30.0; 170 optionsPanel.add(sidelineLabel, gridBagConstraints); 171 172 // 2 ------------------------------------------------------------------- 173 railCountLabel.setText(Bundle.getMessage("RailCountLabelText")); 174 railCountLabel.setToolTipText(Bundle.getMessage("RailCountToolTip")); 175 gridBagConstraints = new java.awt.GridBagConstraints(); 176 gridBagConstraints.gridx = 0; 177 gridBagConstraints.gridy = 2; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 180 optionsPanel.add(railCountLabel, gridBagConstraints); 181 182 mainRailCountSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 0, 3, 1)); 183 mainRailCountSpinner.setToolTipText(Bundle.getMessage("MainRailCountToolTip")); 184 mainRailCountSpinner.setName(""); // NOI18N 185 mainRailCountSpinner.setValue(ltdOptions.getMainRailCount()); 186 mainRailCountSpinner.addChangeListener(this::mainRailCountSpinnerStateChanged); 187 gridBagConstraints = new java.awt.GridBagConstraints(); 188 gridBagConstraints.gridx = 2; 189 gridBagConstraints.gridy = 2; 190 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 191 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 192 optionsPanel.add(mainRailCountSpinner, gridBagConstraints); 193 194 sideRailCountSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 0, 3, 1)); 195 sideRailCountSpinner.setToolTipText(Bundle.getMessage("SideRailCountToolTip")); 196 sideRailCountSpinner.setName(""); // NOI18N 197 sideRailCountSpinner.setValue(ltdOptions.getSideRailCount()); 198 sideRailCountSpinner.addChangeListener(this::sideRailCountSpinnerStateChanged); 199 gridBagConstraints = new java.awt.GridBagConstraints(); 200 gridBagConstraints.gridx = 4; 201 gridBagConstraints.gridy = 2; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 203 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 204 optionsPanel.add(sideRailCountSpinner, gridBagConstraints); 205 206 // 4 ------------------------------------------------------------------- 207 railWidthLabel.setText(Bundle.getMessage("RailWidthLabelText")); 208 railWidthLabel.setToolTipText(Bundle.getMessage("RailWidthToolTip")); 209 gridBagConstraints = new java.awt.GridBagConstraints(); 210 gridBagConstraints.gridx = 0; 211 gridBagConstraints.gridy = 4; 212 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 213 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 214 optionsPanel.add(railWidthLabel, gridBagConstraints); 215 216 mainRailWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(2, 0, null, 1)); 217 mainRailWidthSpinner.setToolTipText(Bundle.getMessage("MainRailWidthToolTip")); 218 mainRailWidthSpinner.setEnabled(ltdOptions.getMainRailCount() > 0); 219 mainRailWidthSpinner.setName(""); // NOI18N 220 mainRailWidthSpinner.setValue(ltdOptions.getMainRailWidth()); 221 mainRailWidthSpinner.addChangeListener(this::mainRailWidthSpinnerStateChanged); 222 gridBagConstraints = new java.awt.GridBagConstraints(); 223 gridBagConstraints.gridx = 2; 224 gridBagConstraints.gridy = 4; 225 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 226 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 227 optionsPanel.add(mainRailWidthSpinner, gridBagConstraints); 228 229 sideRailWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 230 sideRailWidthSpinner.setToolTipText(Bundle.getMessage("SideRailWidthToolTip")); 231 sideRailWidthSpinner.setEnabled(ltdOptions.getSideRailCount() > 0); 232 sideRailWidthSpinner.setName(""); // NOI18N 233 sideRailWidthSpinner.setValue(ltdOptions.getSideRailWidth()); 234 sideRailWidthSpinner.addChangeListener(this::sideRailWidthSpinnerStateChanged); 235 gridBagConstraints = new java.awt.GridBagConstraints(); 236 gridBagConstraints.gridx = 4; 237 gridBagConstraints.gridy = 4; 238 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 239 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 240 optionsPanel.add(sideRailWidthSpinner, gridBagConstraints); 241 242 // 6 ------------------------------------------------------------------- 243 railGapLabel.setText(Bundle.getMessage("RailGapLabelText")); 244 railGapLabel.setToolTipText(Bundle.getMessage("RailGapToolTip")); 245 gridBagConstraints = new java.awt.GridBagConstraints(); 246 gridBagConstraints.gridx = 0; 247 gridBagConstraints.gridy = 6; 248 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 249 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 250 optionsPanel.add(railGapLabel, gridBagConstraints); 251 252 sideRailGapSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, null, 1)); 253 sideRailGapSpinner.setToolTipText(Bundle.getMessage("SideRailGapToolTip")); 254 sideRailGapSpinner.setEnabled(ltdOptions.getSideRailCount() > 1); 255 sideRailGapSpinner.setName(""); // NOI18N 256 sideRailGapSpinner.setValue(ltdOptions.getSideRailGap()); 257 sideRailGapSpinner.addChangeListener(this::sideRailGapSpinnerStateChanged); 258 gridBagConstraints = new java.awt.GridBagConstraints(); 259 gridBagConstraints.gridx = 4; 260 gridBagConstraints.gridy = 6; 261 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 262 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 263 optionsPanel.add(sideRailGapSpinner, gridBagConstraints); 264 265 mainRailGapSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, null, 1)); 266 mainRailGapSpinner.setToolTipText(Bundle.getMessage("MainRailGapToolTip")); 267 mainRailGapSpinner.setEnabled(ltdOptions.getMainRailCount() > 1); 268 mainRailGapSpinner.setName(""); // NOI18N 269 mainRailGapSpinner.setValue(ltdOptions.getMainRailGap()); 270 mainRailGapSpinner.addChangeListener(this::mainRailGapSpinnerStateChanged); 271 gridBagConstraints = new java.awt.GridBagConstraints(); 272 gridBagConstraints.gridx = 2; 273 gridBagConstraints.gridy = 6; 274 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 275 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 276 optionsPanel.add(mainRailGapSpinner, gridBagConstraints); 277 278 // 8 ------------------------------------------------------------------- 279 railColorLabel.setText(Bundle.getMessage("RailColorLabelText")); 280 railColorLabel.setToolTipText(Bundle.getMessage("RailColorToolTip")); 281 gridBagConstraints = new java.awt.GridBagConstraints(); 282 gridBagConstraints.gridx = 0; 283 gridBagConstraints.gridy = 8; 284 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 285 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 286 optionsPanel.add(railColorLabel, gridBagConstraints); 287 288 mainRailColorButton.setBackground(ltdOptions.getMainRailColor()); 289 mainRailColorButton.setToolTipText(Bundle.getMessage("MainRailColorToolTip")); 290 mainRailColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 291 mainRailColorButton.setEnabled(ltdOptions.getMainRailCount() > 0); 292 mainRailColorButton.setOpaque(true); 293 mainRailColorButton.addActionListener(this::mainRailColorButtonActionPerformed); 294 295 javax.swing.GroupLayout mainRailColorButtonLayout = new javax.swing.GroupLayout(mainRailColorButton); 296 mainRailColorButton.setLayout(mainRailColorButtonLayout); 297 mainRailColorButtonLayout.setHorizontalGroup( 298 mainRailColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 299 .addGap(0, 0, Short.MAX_VALUE) 300 ); 301 mainRailColorButtonLayout.setVerticalGroup( 302 mainRailColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 303 .addGap(0, 0, Short.MAX_VALUE) 304 ); 305 306 gridBagConstraints = new java.awt.GridBagConstraints(); 307 gridBagConstraints.gridx = 2; 308 gridBagConstraints.gridy = 8; 309 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 310 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 311 optionsPanel.add(mainRailColorButton, gridBagConstraints); 312 313 sideRailColorButton.setBackground(ltdOptions.getSideRailColor()); 314 sideRailColorButton.setToolTipText(Bundle.getMessage("SideRailColorToolTip")); 315 sideRailColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 316 sideRailColorButton.setEnabled(ltdOptions.getSideRailCount() > 0); 317 sideRailColorButton.setOpaque(true); 318 sideRailColorButton.addActionListener(this::sideRailColorButtonActionPerformed); 319 320 javax.swing.GroupLayout sideRailColorButtonLayout = new javax.swing.GroupLayout(sideRailColorButton); 321 sideRailColorButton.setLayout(sideRailColorButtonLayout); 322 sideRailColorButtonLayout.setHorizontalGroup( 323 sideRailColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 324 .addGap(0, 0, Short.MAX_VALUE) 325 ); 326 sideRailColorButtonLayout.setVerticalGroup( 327 sideRailColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 328 .addGap(0, 0, Short.MAX_VALUE) 329 ); 330 331 gridBagConstraints = new java.awt.GridBagConstraints(); 332 gridBagConstraints.gridx = 4; 333 gridBagConstraints.gridy = 8; 334 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 335 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 336 optionsPanel.add(sideRailColorButton, gridBagConstraints); 337 338 // 10 ------------------------------------------------------------------ 339 blockLineWidthLabel.setText(Bundle.getMessage("BlockLineWidthLabelText")); 340 blockLineWidthLabel.setToolTipText(Bundle.getMessage("BlockLineWidthToolTip")); 341 gridBagConstraints = new java.awt.GridBagConstraints(); 342 gridBagConstraints.gridx = 0; 343 gridBagConstraints.gridy = 10; 344 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 345 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 346 optionsPanel.add(blockLineWidthLabel, gridBagConstraints); 347 348 mainBlockLineWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, null, 1)); 349 mainBlockLineWidthSpinner.setToolTipText(Bundle.getMessage("MainBlockLineWidthToolTip")); 350 mainBlockLineWidthSpinner.setName(""); // NOI18N 351 mainBlockLineWidthSpinner.setValue(ltdOptions.getMainBlockLineWidth()); 352 mainBlockLineWidthSpinner.addChangeListener(this::mainBlockLineWidthSpinnerStateChanged); 353 gridBagConstraints = new java.awt.GridBagConstraints(); 354 gridBagConstraints.gridx = 2; 355 gridBagConstraints.gridy = 10; 356 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 357 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 358 optionsPanel.add(mainBlockLineWidthSpinner, gridBagConstraints); 359 360 sideBlockLineWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, null, 1)); 361 sideBlockLineWidthSpinner.setToolTipText(Bundle.getMessage("SideBlockLineWidthToolTip")); 362 sideBlockLineWidthSpinner.setName(""); // NOI18N 363 sideBlockLineWidthSpinner.setValue(ltdOptions.getSideBlockLineWidth()); 364 sideBlockLineWidthSpinner.addChangeListener(this::sideBlockLineWidthSpinnerStateChanged); 365 gridBagConstraints = new java.awt.GridBagConstraints(); 366 gridBagConstraints.gridx = 4; 367 gridBagConstraints.gridy = 10; 368 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 369 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 370 optionsPanel.add(sideBlockLineWidthSpinner, gridBagConstraints); 371 372 // 12 ------------------------------------------------------------------ 373 blockLineDashPercentageX10Label.setText(Bundle.getMessage("BlockLineDashPercentageX10LabelText")); 374 blockLineDashPercentageX10Label.setToolTipText(Bundle.getMessage("BlockLineDashPercentageX10ToolTip")); 375 gridBagConstraints = new java.awt.GridBagConstraints(); 376 gridBagConstraints.gridx = 0; 377 gridBagConstraints.gridy = 12; 378 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 379 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 380 optionsPanel.add(blockLineDashPercentageX10Label, gridBagConstraints); 381 382 mainBlockLineDashPercentageX10Spinner.setModel(new javax.swing.SpinnerNumberModel(1, 0, 9, 1)); 383 mainBlockLineDashPercentageX10Spinner.setToolTipText(Bundle.getMessage("MainBlockLineWidthToolTip")); 384 mainBlockLineDashPercentageX10Spinner.setEnabled(ltdOptions.getMainBlockLineWidth() > 0); 385 mainBlockLineDashPercentageX10Spinner.setName(""); // NOI18N 386 mainBlockLineDashPercentageX10Spinner.setValue(ltdOptions.getMainBlockLineDashPercentageX10()); 387 mainBlockLineDashPercentageX10Spinner.addChangeListener(this::mainBlockLineDashPercentageX10SpinnerStateChanged); 388 gridBagConstraints = new java.awt.GridBagConstraints(); 389 gridBagConstraints.gridx = 2; 390 gridBagConstraints.gridy = 12; 391 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 392 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 393 optionsPanel.add(mainBlockLineDashPercentageX10Spinner, gridBagConstraints); 394 395 sideBlockLineDashPercentageX10Spinner.setModel(new javax.swing.SpinnerNumberModel(1, 0, 9, 1)); 396 sideBlockLineDashPercentageX10Spinner.setToolTipText(Bundle.getMessage("SideBlockLineDashPercentageX10ToolTip")); 397 sideBlockLineDashPercentageX10Spinner.setEnabled(ltdOptions.getSideBlockLineWidth() > 0); 398 sideBlockLineDashPercentageX10Spinner.setName(""); // NOI18N 399 sideBlockLineDashPercentageX10Spinner.setValue(ltdOptions.getSideBlockLineDashPercentageX10()); 400 sideBlockLineDashPercentageX10Spinner.addChangeListener(this::sideBlockLineDashPercentageX10SpinnerStateChanged); 401 gridBagConstraints = new java.awt.GridBagConstraints(); 402 gridBagConstraints.gridx = 4; 403 gridBagConstraints.gridy = 12; 404 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 405 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 406 optionsPanel.add(sideBlockLineDashPercentageX10Spinner, gridBagConstraints); 407 408 // 14 ------------------------------------------------------------------ 409 blockDefaultColorLabel.setText(Bundle.getMessage("BlockDefaultColorLabelText")); 410 blockDefaultColorLabel.setToolTipText(Bundle.getMessage("BlockDefaultColorToolTip")); 411 gridBagConstraints = new java.awt.GridBagConstraints(); 412 gridBagConstraints.gridx = 0; 413 gridBagConstraints.gridy = 14; 414 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 415 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 416 optionsPanel.add(blockDefaultColorLabel, gridBagConstraints); 417 418 blockDefaultColorButton.setBackground(layoutEditor.getDefaultTrackColorColor()); 419 blockDefaultColorButton.setToolTipText(Bundle.getMessage("BlockDefaultColorToolTip")); 420 blockDefaultColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 421 blockDefaultColorButton.setEnabled(true); 422 blockDefaultColorButton.setOpaque(true); 423 blockDefaultColorButton.addActionListener(this::blockDefaultColorButtonActionPerformed); 424 425 javax.swing.GroupLayout blockDefaultColorButtonLayout = new javax.swing.GroupLayout(blockDefaultColorButton); 426 blockDefaultColorButton.setLayout(blockDefaultColorButtonLayout); 427 blockDefaultColorButtonLayout.setHorizontalGroup( 428 blockDefaultColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 429 .addGap(0, 0, Short.MAX_VALUE) 430 ); 431 blockDefaultColorButtonLayout.setVerticalGroup( 432 blockDefaultColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 433 .addGap(0, 0, Short.MAX_VALUE) 434 ); 435 436 gridBagConstraints = new java.awt.GridBagConstraints(); 437 gridBagConstraints.gridx = 2; 438 gridBagConstraints.gridy = 14; 439 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 440 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 441 optionsPanel.add(blockDefaultColorButton, gridBagConstraints); 442 443 // 16 ------------------------------------------------------------------ 444 blockOccupiedColorLabel.setText(Bundle.getMessage("BlockOccupiedColorLabelText")); 445 blockOccupiedColorLabel.setToolTipText(Bundle.getMessage("BlockOccupiedColorToolTip")); 446 gridBagConstraints = new java.awt.GridBagConstraints(); 447 gridBagConstraints.gridx = 0; 448 gridBagConstraints.gridy = 16; 449 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 450 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 451 optionsPanel.add(blockOccupiedColorLabel, gridBagConstraints); 452 453 blockOccupiedColorButton.setBackground(layoutEditor.getDefaultOccupiedTrackColorColor()); 454 blockOccupiedColorButton.setToolTipText(Bundle.getMessage("BlockOccupiedColorToolTip")); 455 blockOccupiedColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 456 blockOccupiedColorButton.setEnabled(true); 457 blockOccupiedColorButton.setOpaque(true); 458 blockOccupiedColorButton.addActionListener(this::blockOccupiedColorButtonActionPerformed); 459 460 javax.swing.GroupLayout blockOccupiedColorButtonLayout = new javax.swing.GroupLayout(blockOccupiedColorButton); 461 blockOccupiedColorButton.setLayout(blockOccupiedColorButtonLayout); 462 blockOccupiedColorButtonLayout.setHorizontalGroup( 463 blockOccupiedColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 464 .addGap(0, 0, Short.MAX_VALUE) 465 ); 466 blockOccupiedColorButtonLayout.setVerticalGroup( 467 blockOccupiedColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 468 .addGap(0, 0, Short.MAX_VALUE) 469 ); 470 471 gridBagConstraints = new java.awt.GridBagConstraints(); 472 gridBagConstraints.gridx = 2; 473 gridBagConstraints.gridy = 16; 474 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 475 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 476 optionsPanel.add(blockOccupiedColorButton, gridBagConstraints); 477 478 // 18 ------------------------------------------------------------------ 479 blockAlternativeColorLabel.setText(Bundle.getMessage("BlockAlternativeColorLabelText")); 480 blockAlternativeColorLabel.setToolTipText(Bundle.getMessage("BlockAlternativeColorToolTip")); 481 gridBagConstraints = new java.awt.GridBagConstraints(); 482 gridBagConstraints.gridx = 0; 483 gridBagConstraints.gridy = 18; 484 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 485 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 486 optionsPanel.add(blockAlternativeColorLabel, gridBagConstraints); 487 488 blockAlternativeColorButton.setBackground(layoutEditor.getDefaultAlternativeTrackColorColor()); 489 blockAlternativeColorButton.setToolTipText(Bundle.getMessage("BlockAlternativeColorToolTip")); 490 blockAlternativeColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 491 blockAlternativeColorButton.setEnabled(true); 492 blockAlternativeColorButton.setOpaque(true); 493 blockAlternativeColorButton.addActionListener(this::blockAlternativeColorButtonActionPerformed); 494 495 javax.swing.GroupLayout blockAlternativeColorButtonLayout = new javax.swing.GroupLayout(blockAlternativeColorButton); 496 blockAlternativeColorButton.setLayout(blockAlternativeColorButtonLayout); 497 blockAlternativeColorButtonLayout.setHorizontalGroup( 498 blockAlternativeColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 499 .addGap(0, 0, Short.MAX_VALUE) 500 ); 501 blockAlternativeColorButtonLayout.setVerticalGroup( 502 blockAlternativeColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 503 .addGap(0, 0, Short.MAX_VALUE) 504 ); 505 506 gridBagConstraints = new java.awt.GridBagConstraints(); 507 gridBagConstraints.gridx = 2; 508 gridBagConstraints.gridy = 18; 509 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 510 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 511 optionsPanel.add(blockAlternativeColorButton, gridBagConstraints); 512 513 // 20 ------------------------------------------------------------------ 514 ballastWidthLabel.setText(Bundle.getMessage("BallastWidthLabelText")); 515 ballastWidthLabel.setToolTipText(Bundle.getMessage("BallastWidthToolTip")); 516 gridBagConstraints = new java.awt.GridBagConstraints(); 517 gridBagConstraints.gridx = 0; 518 gridBagConstraints.gridy = 20; 519 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 520 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 521 optionsPanel.add(ballastWidthLabel, gridBagConstraints); 522 523 mainBallastWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 524 mainBallastWidthSpinner.setToolTipText(Bundle.getMessage("MainBallastWidthToolTip")); 525 mainBallastWidthSpinner.setValue(ltdOptions.getMainBallastWidth()); 526 mainBallastWidthSpinner.addChangeListener(this::mainBallastWidthSpinnerStateChanged); 527 gridBagConstraints = new java.awt.GridBagConstraints(); 528 gridBagConstraints.gridx = 2; 529 gridBagConstraints.gridy = 20; 530 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 531 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 532 optionsPanel.add(mainBallastWidthSpinner, gridBagConstraints); 533 534 sideBallastWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 535 sideBallastWidthSpinner.setToolTipText(Bundle.getMessage("SideBallastWidthToolTip")); 536 sideBallastWidthSpinner.setValue(ltdOptions.getSideBallastWidth()); 537 sideBallastWidthSpinner.addChangeListener(this::sideBallastWidthSpinnerStateChanged); 538 gridBagConstraints = new java.awt.GridBagConstraints(); 539 gridBagConstraints.gridx = 4; 540 gridBagConstraints.gridy = 20; 541 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 542 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 543 optionsPanel.add(sideBallastWidthSpinner, gridBagConstraints); 544 545 // 22 ------------------------------------------------------------------ 546 ballastColorLabel.setText(Bundle.getMessage("BallastColorLabelText")); 547 ballastColorLabel.setToolTipText(Bundle.getMessage("BallastColorToolTip")); 548 gridBagConstraints = new java.awt.GridBagConstraints(); 549 gridBagConstraints.gridx = 0; 550 gridBagConstraints.gridy = 22; 551 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 552 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 553 optionsPanel.add(ballastColorLabel, gridBagConstraints); 554 555 mainBallastColorButton.setBackground(ltdOptions.getMainBallastColor()); 556 mainBallastColorButton.setToolTipText(Bundle.getMessage("MainBallastColorToolTip")); 557 mainBallastColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 558 mainBallastColorButton.setEnabled(ltdOptions.getMainBallastWidth() > 0); 559 mainBallastColorButton.setOpaque(true); 560 mainBallastColorButton.addActionListener(this::mainBallastColorButtonActionPerformed); 561 562 javax.swing.GroupLayout mainBallastColorButtonLayout = new javax.swing.GroupLayout(mainBallastColorButton); 563 mainBallastColorButton.setLayout(mainBallastColorButtonLayout); 564 mainBallastColorButtonLayout.setHorizontalGroup( 565 mainBallastColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 566 .addGap(0, 0, Short.MAX_VALUE) 567 ); 568 mainBallastColorButtonLayout.setVerticalGroup( 569 mainBallastColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 570 .addGap(0, 0, Short.MAX_VALUE) 571 ); 572 573 gridBagConstraints = new java.awt.GridBagConstraints(); 574 gridBagConstraints.gridx = 2; 575 gridBagConstraints.gridy = 22; 576 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 577 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 578 optionsPanel.add(mainBallastColorButton, gridBagConstraints); 579 580 sideBallastColorButton.setBackground(ltdOptions.getSideBallastColor()); 581 sideBallastColorButton.setToolTipText(Bundle.getMessage("SideBallastColorToolTip")); 582 sideBallastColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 583 sideBallastColorButton.setEnabled(ltdOptions.getSideBallastWidth() > 0); 584 sideBallastColorButton.setOpaque(true); 585 sideBallastColorButton.addActionListener(this::sideBallastColorButtonActionPerformed); 586 587 javax.swing.GroupLayout sideBallastColorButtonLayout = new javax.swing.GroupLayout(sideBallastColorButton); 588 sideBallastColorButton.setLayout(sideBallastColorButtonLayout); 589 sideBallastColorButtonLayout.setHorizontalGroup( 590 sideBallastColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 591 .addGap(0, 0, Short.MAX_VALUE) 592 ); 593 sideBallastColorButtonLayout.setVerticalGroup( 594 sideBallastColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 595 .addGap(0, 0, Short.MAX_VALUE) 596 ); 597 598 gridBagConstraints = new java.awt.GridBagConstraints(); 599 gridBagConstraints.gridx = 4; 600 gridBagConstraints.gridy = 22; 601 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 602 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 603 optionsPanel.add(sideBallastColorButton, gridBagConstraints); 604 605 // 24 ------------------------------------------------------------------ 606 tieLengthLabel.setText(Bundle.getMessage("TieLengthLabelText")); 607 tieLengthLabel.setToolTipText(Bundle.getMessage("TieLengthToolTip")); 608 gridBagConstraints = new java.awt.GridBagConstraints(); 609 gridBagConstraints.gridx = 0; 610 gridBagConstraints.gridy = 24; 611 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 612 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 613 optionsPanel.add(tieLengthLabel, gridBagConstraints); 614 615 mainTieLengthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 616 mainTieLengthSpinner.setToolTipText(Bundle.getMessage("MainTieLengthToolTip")); 617 mainTieLengthSpinner.setValue(ltdOptions.getMainTieLength()); 618 mainTieLengthSpinner.addChangeListener(this::mainTieLengthSpinnerStateChanged); 619 gridBagConstraints = new java.awt.GridBagConstraints(); 620 gridBagConstraints.gridx = 2; 621 gridBagConstraints.gridy = 24; 622 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 623 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 624 optionsPanel.add(mainTieLengthSpinner, gridBagConstraints); 625 626 sideTieLengthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 627 sideTieLengthSpinner.setToolTipText(Bundle.getMessage("SideTieLengthToolTip")); 628 sideTieLengthSpinner.setValue(ltdOptions.getSideTieLength()); 629 sideTieLengthSpinner.addChangeListener(this::sideTieLengthSpinnerStateChanged); 630 gridBagConstraints = new java.awt.GridBagConstraints(); 631 gridBagConstraints.gridx = 4; 632 gridBagConstraints.gridy = 24; 633 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 634 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 635 optionsPanel.add(sideTieLengthSpinner, gridBagConstraints); 636 637 // 26 ------------------------------------------------------------------ 638 tieWidthLabel.setText(Bundle.getMessage("TieWidthLabelText")); 639 tieWidthLabel.setToolTipText(Bundle.getMessage("TieWidthToolTip")); 640 gridBagConstraints = new java.awt.GridBagConstraints(); 641 gridBagConstraints.gridx = 0; 642 gridBagConstraints.gridy = 26; 643 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 644 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 645 optionsPanel.add(tieWidthLabel, gridBagConstraints); 646 647 mainTieWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 648 mainTieWidthSpinner.setToolTipText(Bundle.getMessage("MainTieWidthToolTip")); 649 mainTieWidthSpinner.setEnabled(ltdOptions.getMainTieLength() > 0); 650 mainTieWidthSpinner.setValue(ltdOptions.getMainTieWidth()); 651 mainTieWidthSpinner.addChangeListener(this::mainTieWidthSpinnerStateChanged); 652 gridBagConstraints = new java.awt.GridBagConstraints(); 653 gridBagConstraints.gridx = 2; 654 gridBagConstraints.gridy = 26; 655 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 656 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 657 optionsPanel.add(mainTieWidthSpinner, gridBagConstraints); 658 659 sideTieWidthSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 660 sideTieWidthSpinner.setToolTipText(Bundle.getMessage("SideTieWidthToolTip")); 661 sideTieWidthSpinner.setEnabled(ltdOptions.getSideTieLength() > 0); 662 sideTieWidthSpinner.setValue(ltdOptions.getSideTieWidth()); 663 sideTieWidthSpinner.addChangeListener(this::sideTieWidthSpinnerStateChanged); 664 gridBagConstraints = new java.awt.GridBagConstraints(); 665 gridBagConstraints.gridx = 4; 666 gridBagConstraints.gridy = 26; 667 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 668 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 669 optionsPanel.add(sideTieWidthSpinner, gridBagConstraints); 670 671 // 28 ------------------------------------------------------------------ 672 tieGapLabel.setText(Bundle.getMessage("TieGapLabelText")); 673 tieGapLabel.setToolTipText(Bundle.getMessage("TieGapToolTip")); 674 gridBagConstraints = new java.awt.GridBagConstraints(); 675 gridBagConstraints.gridx = 0; 676 gridBagConstraints.gridy = 28; 677 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 678 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 679 optionsPanel.add(tieGapLabel, gridBagConstraints); 680 681 mainTieGapSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 682 mainTieGapSpinner.setToolTipText(Bundle.getMessage("MainTieGapToolTip")); 683 mainTieGapSpinner.setEnabled(ltdOptions.getMainTieLength() > 0); 684 mainTieGapSpinner.setValue(ltdOptions.getMainTieGap()); 685 mainTieGapSpinner.addChangeListener(this::mainTieGapSpinnerStateChanged); 686 gridBagConstraints = new java.awt.GridBagConstraints(); 687 gridBagConstraints.gridx = 2; 688 gridBagConstraints.gridy = 28; 689 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 690 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 691 optionsPanel.add(mainTieGapSpinner, gridBagConstraints); 692 693 sideTieGapSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); 694 sideTieGapSpinner.setToolTipText(Bundle.getMessage("SideTieGapToolTip")); 695 sideTieGapSpinner.setEnabled(ltdOptions.getSideTieLength() > 0); 696 sideTieGapSpinner.setValue(ltdOptions.getSideTieGap()); 697 sideTieGapSpinner.addChangeListener(this::sideTieGapSpinnerStateChanged); 698 gridBagConstraints = new java.awt.GridBagConstraints(); 699 gridBagConstraints.gridx = 4; 700 gridBagConstraints.gridy = 28; 701 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 702 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 703 optionsPanel.add(sideTieGapSpinner, gridBagConstraints); 704 705 // 30 ------------------------------------------------------------------ 706 tieColorLabel.setText(Bundle.getMessage("TieColorLabelText")); 707 tieColorLabel.setToolTipText(Bundle.getMessage("TieColorToolTip")); 708 gridBagConstraints = new java.awt.GridBagConstraints(); 709 gridBagConstraints.gridx = 0; 710 gridBagConstraints.gridy = 30; 711 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 712 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE_LEADING; 713 optionsPanel.add(tieColorLabel, gridBagConstraints); 714 715 mainTieColorButton.setBackground(ltdOptions.getMainTieColor()); 716 mainTieColorButton.setToolTipText(Bundle.getMessage("MainTieColorToolTip")); 717 mainTieColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 718 mainTieColorButton.setEnabled(ltdOptions.getMainTieLength() > 0); 719 mainTieColorButton.setOpaque(true); 720 mainTieColorButton.addActionListener(this::mainTieColorButtonActionPerformed); 721 722 javax.swing.GroupLayout mainTieColorButtonLayout = new javax.swing.GroupLayout(mainTieColorButton); 723 mainTieColorButton.setLayout(mainTieColorButtonLayout); 724 mainTieColorButtonLayout.setHorizontalGroup( 725 mainTieColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 726 .addGap(0, 0, Short.MAX_VALUE) 727 ); 728 mainTieColorButtonLayout.setVerticalGroup( 729 mainTieColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 730 .addGap(0, 0, Short.MAX_VALUE) 731 ); 732 733 gridBagConstraints = new java.awt.GridBagConstraints(); 734 gridBagConstraints.gridx = 2; 735 gridBagConstraints.gridy = 30; 736 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 737 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 738 optionsPanel.add(mainTieColorButton, gridBagConstraints); 739 740 sideTieColorButton.setBackground(ltdOptions.getSideTieColor()); 741 sideTieColorButton.setToolTipText(Bundle.getMessage("SideTieColorToolTip")); 742 sideTieColorButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 743 sideTieColorButton.setEnabled(ltdOptions.getSideTieLength() > 0); 744 sideTieColorButton.setOpaque(true); 745 sideTieColorButton.addActionListener(this::sideTieColorButtonActionPerformed); 746 747 javax.swing.GroupLayout sideTieColorButtonLayout = new javax.swing.GroupLayout(sideTieColorButton); 748 sideTieColorButton.setLayout(sideTieColorButtonLayout); 749 sideTieColorButtonLayout.setHorizontalGroup( 750 sideTieColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 751 .addGap(0, 0, Short.MAX_VALUE) 752 ); 753 sideTieColorButtonLayout.setVerticalGroup( 754 sideTieColorButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 755 .addGap(0, 0, Short.MAX_VALUE) 756 ); 757 758 gridBagConstraints = new java.awt.GridBagConstraints(); 759 gridBagConstraints.gridx = 4; 760 gridBagConstraints.gridy = 30; 761 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 762 gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; 763 optionsPanel.add(sideTieColorButton, gridBagConstraints); 764 765 presetsLabel.setText(Bundle.getMessage("ButtonPresets")); 766 767 presetsComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Classic JMRI", "Drafting", "Realistic", "Realistic Oh!", "Garrish", "--", "Custom" })); 768 presetsComboBox.addActionListener(this::presetsComboBoxActionPerformed); 769 770 applyButton.setText(Bundle.getMessage("ButtonApply")); 771 applyButton.addActionListener(this::applyButtonActionPerformed); 772 773 cancelButton.setText(Bundle.getMessage("ButtonCancel")); 774 cancelButton.setActionCommand("cancelActionCommand"); 775 cancelButton.addActionListener(this::cancelButtonActionPerformed); 776 777 okButton.setText(Bundle.getMessage("ButtonOK")); 778 okButton.addActionListener(this::okButtonActionPerformed); 779 780 javax.swing.GroupLayout jPanelButtonsLayout = new javax.swing.GroupLayout(jPanelButtons); 781 jPanelButtons.setLayout(jPanelButtonsLayout); 782 jPanelButtonsLayout.setHorizontalGroup( 783 jPanelButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 784 .addGroup(jPanelButtonsLayout.createSequentialGroup() 785 .addContainerGap() 786 .addComponent(presetsLabel) 787 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 788 .addComponent(presetsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) 789 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 285, Short.MAX_VALUE) 790 .addComponent(applyButton) 791 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 792 .addComponent(cancelButton) 793 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 794 .addComponent(okButton) 795 .addContainerGap()) 796 ); 797 798 jPanelButtonsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, applyButton, cancelButton, okButton); 799 800 jPanelButtonsLayout.setVerticalGroup( 801 jPanelButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 802 .addGroup(jPanelButtonsLayout.createSequentialGroup() 803 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 804 .addGroup(jPanelButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 805 .addComponent(presetsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 806 .addComponent(presetsLabel) 807 .addComponent(applyButton) 808 .addComponent(cancelButton) 809 .addComponent(okButton)) 810 .addContainerGap()) 811 ); 812 813 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 814 getContentPane().setLayout(layout); 815 layout.setHorizontalGroup( 816 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 817 .addComponent(optionsPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 722, Short.MAX_VALUE) 818 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 819 .addComponent(jPanelButtons, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 820 ); 821 layout.setVerticalGroup( 822 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 823 .addGroup(layout.createSequentialGroup() 824 .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 632, javax.swing.GroupLayout.PREFERRED_SIZE) 825 .addGap(0, 68, Short.MAX_VALUE)) 826 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 827 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 828 .addGap(0, 542, Short.MAX_VALUE) 829 .addComponent(jPanelButtons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) 830 ); 831 832 pack(); 833 }// </editor-fold>//GEN-END:initComponents 834 835 /*==========================*\ 836 |* action performed methods *| 837 \*==========================*/ 838 839 /*************************************************************************** 840 * OK button action performed. 841 * Non-systemic color adjustment solution for blockDefaultColor, blockOccupiedColor and blockAlternativeColor. 842 * 843 * @param evt event 844 */ 845 private void okButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed 846 log.debug("okButtonActionPerformed({}", evt); 847 848 // ---------------------------------------- 849 layoutEditor.setDefaultTrackColor(ltdOptions.getBlockDefaultColor()); 850 layoutEditor.setDefaultOccupiedTrackColor(ltdOptions.getBlockOccupiedColor()); 851 layoutEditor.setDefaultAlternativeTrackColor(ltdOptions.getBlockAlternativeColor()); 852 layoutEditor.setDirty(); 853 layoutEditor.redrawPanel(); 854 // ---------------------------------------- 855 856 ltdOptions.setName(layoutEditor.getLayoutName()); 857 layoutEditor.setLayoutTrackDrawingOptions(ltdOptions); 858 ltdOptions = null; 859 setVisible(false); 860 dispose(); 861 }//GEN-LAST:event_okButtonActionPerformed 862 863 /*************************************************************************** 864 * Apply button action performed. 865 * Non-systemic color adjustment solution for blockDefaultColor, blockOccupiedColor and blockAlternativeColor. 866 * 867 * @param evt event 868 */ 869 private void applyButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed 870 871 // ---------------------------------------- 872 layoutEditor.setDefaultTrackColor(ltdOptions.getBlockDefaultColor()); 873 layoutEditor.setDefaultOccupiedTrackColor(ltdOptions.getBlockOccupiedColor()); 874 layoutEditor.setDefaultAlternativeTrackColor(ltdOptions.getBlockAlternativeColor()); 875 layoutEditor.setDirty(); 876 layoutEditor.redrawPanel(); 877 // ---------------------------------------- 878 879 LayoutTrackDrawingOptions ltdo = new LayoutTrackDrawingOptions(ltdOptions); 880 ltdo.setName(layoutEditor.getLayoutName()); 881 layoutEditor.setLayoutTrackDrawingOptions(ltdo); 882 }//GEN-LAST:event_applyButtonActionPerformed 883 884 private void presetsComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:event_presetsComboBoxActionPerformed 885 log.debug("presetsComboBoxActionPerformed({}", evt); 886 int modifiers = evt.getModifiers(); 887 if (modifiers != 0) { // don't do this unless it's a mouse click 888 String presetName = (String) presetsComboBox.getSelectedItem(); 889 for (LayoutTrackDrawingOptions ltdo : ltdoList) { 890 if (ltdo.getName().equals(presetName)) { 891 if (!ltdOptions.getName().equals(ltdo.getName())) { 892 ltdOptions = ltdo; 893 setupControls(); 894 optionsPanel.setBorder(BorderFactory.createTitledBorder(presetName)); 895 presetsComboBox.setSelectedItem(presetName); 896 } 897 break; 898 } 899 } 900 } 901 }//GEN-LAST:event_presetsComboBoxActionPerformed 902 903 private void cancelButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed 904 log.debug("cancelButtonActionPerformed({}", evt); 905 // restore orginal settings 906 layoutEditor.setLayoutTrackDrawingOptions(leLTDOptions); 907 setVisible(false); 908 dispose(); 909 }//GEN-LAST:event_cancelButtonActionPerformed 910 911 private void sideTieGapSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideTieGapSpinnerStateChanged 912 JSpinner spinner = (JSpinner) evt.getSource(); 913 Integer value = (Integer) spinner.getValue(); 914 makeCustomPreset(); 915 ltdOptions.setSideTieGap(value); 916 log.debug("sideTieGapSpinnerStateChanged({})", value); 917 }//GEN-LAST:event_sideTieGapSpinnerStateChanged 918 919 private void mainTieGapSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainTieGapSpinnerStateChanged 920 JSpinner spinner = (JSpinner) evt.getSource(); 921 Integer value = (Integer) spinner.getValue(); 922 makeCustomPreset(); 923 ltdOptions.setMainTieGap(value); 924 log.debug("mainTieGapSpinnerStateChanged({})", value); 925 }//GEN-LAST:event_mainTieGapSpinnerStateChanged 926 927 private void sideTieWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideTieWidthSpinnerStateChanged 928 JSpinner spinner = (JSpinner) evt.getSource(); 929 Integer value = (Integer) spinner.getValue(); 930 makeCustomPreset(); 931 ltdOptions.setSideTieWidth(value); 932 log.debug("sideTieWidthSpinnerStateChanged({})", value); 933 }//GEN-LAST:event_sideTieWidthSpinnerStateChanged 934 935 private void mainTieWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainTieWidthSpinnerStateChanged 936 JSpinner spinner = (JSpinner) evt.getSource(); 937 Integer value = (Integer) spinner.getValue(); 938 makeCustomPreset(); 939 ltdOptions.setMainTieWidth(value); 940 log.debug("mainTieWidthSpinnerStateChanged({})", value); 941 }//GEN-LAST:event_mainTieWidthSpinnerStateChanged 942 943 private void sideTieLengthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideTieLengthSpinnerStateChanged 944 JSpinner spinner = (JSpinner) evt.getSource(); 945 Integer value = (Integer) spinner.getValue(); 946 makeCustomPreset(); 947 ltdOptions.setSideTieLength(value); 948 log.debug("sideTieLengthSpinnerStateChanged({})", value); 949 sideTieColorButton.setEnabled(value > 0); 950 sideTieGapSpinner.setEnabled(value > 0); 951 sideTieWidthSpinner.setEnabled(value > 0); 952 }//GEN-LAST:event_sideTieLengthSpinnerStateChanged 953 954 private void mainTieLengthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainTieLengthSpinnerStateChanged 955 JSpinner spinner = (JSpinner) evt.getSource(); 956 Integer value = (Integer) spinner.getValue(); 957 makeCustomPreset(); 958 ltdOptions.setMainTieLength(value); 959 log.debug("mainTieLengthSpinnerStateChanged({})", value); 960 mainTieColorButton.setEnabled(value > 0); 961 mainTieGapSpinner.setEnabled(value > 0); 962 mainTieWidthSpinner.setEnabled(value > 0); 963 }//GEN-LAST:event_mainTieLengthSpinnerStateChanged 964 965 private void sideBallastWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideBallastWidthSpinnerStateChanged 966 JSpinner spinner = (JSpinner) evt.getSource(); 967 Integer value = (Integer) spinner.getValue(); 968 makeCustomPreset(); 969 ltdOptions.setSideBallastWidth(value); 970 log.debug("sideBallastWidthSpinnerStateChanged({})", value); 971 }//GEN-LAST:event_sideBallastWidthSpinnerStateChanged 972 973 private void mainBallastWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainBallastWidthSpinnerStateChanged 974 JSpinner spinner = (JSpinner) evt.getSource(); 975 Integer value = (Integer) spinner.getValue(); 976 makeCustomPreset(); 977 ltdOptions.setMainBallastWidth(value); 978 log.debug("mainBallastWidthSpinnerStateChanged({})", value); 979 }//GEN-LAST:event_mainBallastWidthSpinnerStateChanged 980 981 private void sideBlockLineWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideBlockLineWidthSpinnerStateChanged 982 JSpinner spinner = (JSpinner) evt.getSource(); 983 Integer value = (Integer) spinner.getValue(); 984 makeCustomPreset(); 985 ltdOptions.setSideBlockLineWidth(value); 986 log.debug("sideBlockLineWidthSpinnerStateChanged({})", value); 987 sideBlockLineDashPercentageX10Spinner.setEnabled(value > 0); 988 }//GEN-LAST:event_sideBlockLineWidthSpinnerStateChanged 989 990 private void mainBlockLineWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainBlockLineWidthSpinnerStateChanged 991 JSpinner spinner = (JSpinner) evt.getSource(); 992 Integer value = (Integer) spinner.getValue(); 993 makeCustomPreset(); 994 ltdOptions.setMainBlockLineWidth(value); 995 log.debug("mainBlockLineWidthSpinnerStateChanged({})", value); 996 mainBlockLineDashPercentageX10Spinner.setEnabled(value > 0); 997 }//GEN-LAST:event_mainBlockLineWidthSpinnerStateChanged 998 999 private void mainRailGapSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainRailGapSpinnerStateChanged 1000 JSpinner spinner = (JSpinner) evt.getSource(); 1001 Integer value = (Integer) spinner.getValue(); 1002 makeCustomPreset(); 1003 ltdOptions.setMainRailGap(value); 1004 log.debug("sideRailGapSpinnerStateChanged({})", value); 1005 }//GEN-LAST:event_mainRailGapSpinnerStateChanged 1006 1007 private void sideRailGapSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideRailGapSpinnerStateChanged 1008 JSpinner spinner = (JSpinner) evt.getSource(); 1009 Integer value = (Integer) spinner.getValue(); 1010 makeCustomPreset(); 1011 ltdOptions.setSideRailGap(value); 1012 log.debug("mainRailGapSpinnerStateChanged({})", value); 1013 }//GEN-LAST:event_sideRailGapSpinnerStateChanged 1014 1015 private void sideRailWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideRailWidthSpinnerStateChanged 1016 JSpinner spinner = (JSpinner) evt.getSource(); 1017 Integer value = (Integer) spinner.getValue(); 1018 makeCustomPreset(); 1019 ltdOptions.setSideRailWidth(value); 1020 log.debug("sideRailWidthSpinnerStateChanged({})", value); 1021 }//GEN-LAST:event_sideRailWidthSpinnerStateChanged 1022 1023 private void mainRailWidthSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainRailWidthSpinnerStateChanged 1024 JSpinner spinner = (JSpinner) evt.getSource(); 1025 Integer value = (Integer) spinner.getValue(); 1026 makeCustomPreset(); 1027 ltdOptions.setMainRailWidth(value); 1028 log.debug("mainRailWidthSpinnerStateChanged({})", value); 1029 }//GEN-LAST:event_mainRailWidthSpinnerStateChanged 1030 1031 private void sideRailCountSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideRailCountSpinnerStateChanged 1032 JSpinner spinner = (JSpinner) evt.getSource(); 1033 Integer value = (Integer) spinner.getValue(); 1034 makeCustomPreset(); 1035 ltdOptions.setSideRailCount(value); 1036 log.debug("sideRailCountSpinnerStateChanged({})", value); 1037 sideRailColorButton.setEnabled(value > 0); 1038 sideRailGapSpinner.setEnabled(value > 1); 1039 sideRailWidthSpinner.setEnabled(value > 0); 1040 }//GEN-LAST:event_sideRailCountSpinnerStateChanged 1041 1042 private void mainRailCountSpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainRailCountSpinnerStateChanged 1043 JSpinner spinner = (JSpinner) evt.getSource(); 1044 Integer value = (Integer) spinner.getValue(); 1045 makeCustomPreset(); 1046 ltdOptions.setMainRailCount(value); 1047 log.debug("mainRailCountSpinnerStateChanged({})", value); 1048 mainRailColorButton.setEnabled(value > 0); 1049 mainRailGapSpinner.setEnabled(value > 1); 1050 mainRailWidthSpinner.setEnabled(value > 0); 1051 }//GEN-LAST:event_mainRailCountSpinnerStateChanged 1052 1053 private void mainRailColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_mainRailColorButtonActionPerformed 1054 JButton button = (JButton) evt.getSource(); 1055 Color value = button.getBackground(); 1056 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1057 if ((newColor != null) && !newColor.equals(value)) { 1058 makeCustomPreset(); 1059 button.setBackground(newColor); 1060 ltdOptions.setMainRailColor(newColor); 1061 } 1062 log.info("*mainRailColorButtonActionPerformed({})", newColor); 1063 }//GEN-LAST:event_mainRailColorButtonActionPerformed 1064 1065 private void sideRailColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sideRailColorButtonActionPerformed 1066 JButton button = (JButton) evt.getSource(); 1067 Color value = button.getBackground(); 1068 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1069 if ((newColor != null) && !newColor.equals(value)) { 1070 makeCustomPreset(); 1071 button.setBackground(newColor); 1072 ltdOptions.setSideRailColor(newColor); 1073 } 1074 log.info("*sideRailColorButtonActionPerformed({})", newColor); 1075 }//GEN-LAST:event_sideRailColorButtonActionPerformed 1076 1077 private void mainBallastColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_mainBallastColorButtonActionPerformed 1078 JButton button = (JButton) evt.getSource(); 1079 Color value = button.getBackground(); 1080 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1081 if ((newColor != null) && !newColor.equals(value)) { 1082 makeCustomPreset(); 1083 button.setBackground(newColor); 1084 ltdOptions.setMainBallastColor(newColor); 1085 } 1086 log.info("*mainBallastColorButtonActionPerformed({})", newColor); 1087 }//GEN-LAST:event_mainBallastColorButtonActionPerformed 1088 1089 private void sideBallastColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sideBallastColorButtonActionPerformed 1090 JButton button = (JButton) evt.getSource(); 1091 Color value = button.getBackground(); 1092 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1093 if ((newColor != null) && !newColor.equals(value)) { 1094 makeCustomPreset(); 1095 button.setBackground(newColor); 1096 ltdOptions.setSideBallastColor(newColor); 1097 } 1098 log.info("*sideBallastColorButtonActionPerformed({})", newColor); 1099 }//GEN-LAST:event_sideBallastColorButtonActionPerformed 1100 1101 private void mainTieColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_mainTieColorButtonActionPerformed 1102 JButton button = (JButton) evt.getSource(); 1103 Color value = button.getBackground(); 1104 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1105 if ((newColor != null) && !newColor.equals(value)) { 1106 makeCustomPreset(); 1107 button.setBackground(newColor); 1108 ltdOptions.setMainTieColor(newColor); 1109 } 1110 log.info("*mainTieColorButtonActionPerformed({})", newColor); 1111 }//GEN-LAST:event_mainTieColorButtonActionPerformed 1112 1113 private void sideTieColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_sideTieColorButtonActionPerformed 1114 JButton button = (JButton) evt.getSource(); 1115 Color value = button.getBackground(); 1116 Color newColor = JmriColorChooser.showDialog(null, "Choose a color", value); 1117 if ((newColor != null) && !newColor.equals(value)) { 1118 makeCustomPreset(); 1119 button.setBackground(newColor); 1120 ltdOptions.setSideTieColor(newColor); 1121 } 1122 log.info("*sideTieColorButtonActionPerformed({})", newColor); 1123 }//GEN-LAST:event_sideTieColorButtonActionPerformed 1124 1125 private void blockDefaultColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_blockDefaultColorButtonActionPerformed 1126 JButton button = (JButton) evt.getSource(); 1127 Color value = button.getBackground(); 1128 Color newColor = JmriColorChooser.showDialog(null, Bundle.getMessage("DefaultTrackColor"), value); 1129 if ((newColor != null) && !newColor.equals(value)) { 1130 makeCustomPreset(); 1131 button.setBackground(newColor); 1132 ltdOptions.setBlockDefaultColor(newColor); 1133 } 1134 log.info("*blockDefaultColorButtonActionPerformed({})", newColor); 1135 }//GEN-LAST:event_blockDefaultColorButtonActionPerformed 1136 1137 private void blockOccupiedColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_blockOccupiedColorButtonActionPerformed 1138 JButton button = (JButton) evt.getSource(); 1139 Color value = button.getBackground(); 1140 Color newColor = JmriColorChooser.showDialog(null, Bundle.getMessage("DefaultOccupiedTrackColor"), value); 1141 if ((newColor != null) && !newColor.equals(value)) { 1142 makeCustomPreset(); 1143 button.setBackground(newColor); 1144 ltdOptions.setBlockOccupiedColor(newColor); 1145 } 1146 log.info("*blockOccupiedColorButtonActionPerformed({})", newColor); 1147 }//GEN-LAST:event_blockOccupiedColorButtonActionPerformed 1148 1149 private void blockAlternativeColorButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_blockAlternativeColorButtonActionPerformed 1150 JButton button = (JButton) evt.getSource(); 1151 Color value = button.getBackground(); 1152 Color newColor = JmriColorChooser.showDialog(null, Bundle.getMessage("DefaultAlternativeTrackColor"), value); 1153 if ((newColor != null) && !newColor.equals(value)) { 1154 makeCustomPreset(); 1155 button.setBackground(newColor); 1156 ltdOptions.setBlockAlternativeColor(newColor); 1157 } 1158 log.info("*blockAlternativeColorButtonActionPerformed({})", newColor); 1159 }//GEN-LAST:event_blockAlternativeColorButtonActionPerformed 1160 1161 1162 private void mainBlockLineDashPercentageX10SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_mainBlockLineDashPercentageX10SpinnerStateChanged 1163 JSpinner spinner = (JSpinner) evt.getSource(); 1164 Integer value = (Integer) spinner.getValue(); 1165 makeCustomPreset(); 1166 ltdOptions.setMainBlockLineDashPercentageX10(value); 1167 log.debug("mainBlockLineDashPercentageX10SpinnerStateChanged({})", value); 1168 }//GEN-LAST:event_mainBlockLineDashPercentageX10SpinnerStateChanged 1169 1170 private void sideBlockLineDashPercentageX10SpinnerStateChanged(ChangeEvent evt) {//GEN-FIRST:event_sideBlockLineDashPercentageX10SpinnerStateChanged 1171 JSpinner spinner = (JSpinner) evt.getSource(); 1172 Integer value = (Integer) spinner.getValue(); 1173 makeCustomPreset(); 1174 ltdOptions.setSideBlockLineDashPercentageX10(value); 1175 log.debug("sideBlockLineDashPercentageX10({})", value); 1176 }//GEN-LAST:event_sideBlockLineDashPercentageX10SpinnerStateChanged 1177 1178 /*=========================*\ 1179 |* local (private) methods *| 1180 \*=========================*/ 1181 private void setupControls() { 1182 copyToCustom = false; // prevent xxx.setValue's from creating custom preset 1183 1184 blockDefaultColorButton.setBackground(ltdOptions.getBlockDefaultColor()); 1185 blockOccupiedColorButton.setBackground(ltdOptions.getBlockOccupiedColor()); 1186 blockAlternativeColorButton.setBackground(ltdOptions.getBlockAlternativeColor()); 1187 1188 mainBallastColorButton.setBackground(ltdOptions.getMainBallastColor()); 1189 mainBallastWidthSpinner.setValue(ltdOptions.getMainBallastWidth()); 1190 mainBlockLineDashPercentageX10Spinner.setValue(ltdOptions.getMainBlockLineDashPercentageX10()); 1191 mainBlockLineWidthSpinner.setValue(ltdOptions.getMainBlockLineWidth()); 1192 mainRailColorButton.setBackground(ltdOptions.getMainRailColor()); 1193 mainRailCountSpinner.setValue(ltdOptions.getMainRailCount()); 1194 mainRailGapSpinner.setValue(ltdOptions.getMainRailGap()); 1195 mainRailWidthSpinner.setValue(ltdOptions.getMainRailWidth()); 1196 mainTieColorButton.setBackground(ltdOptions.getMainTieColor()); 1197 mainTieGapSpinner.setValue(ltdOptions.getMainTieGap()); 1198 mainTieLengthSpinner.setValue(ltdOptions.getMainTieLength()); 1199 mainTieWidthSpinner.setValue(ltdOptions.getMainTieWidth()); 1200 sideBallastColorButton.setBackground(ltdOptions.getSideBallastColor()); 1201 sideBallastWidthSpinner.setValue(ltdOptions.getSideBallastWidth()); 1202 sideBlockLineDashPercentageX10Spinner.setValue(ltdOptions.getSideBlockLineDashPercentageX10()); 1203 sideBlockLineWidthSpinner.setValue(ltdOptions.getSideBlockLineWidth()); 1204 sideRailColorButton.setBackground(ltdOptions.getSideRailColor()); 1205 sideRailCountSpinner.setValue(ltdOptions.getSideRailCount()); 1206 sideRailGapSpinner.setValue(ltdOptions.getSideRailGap()); 1207 sideRailWidthSpinner.setValue(ltdOptions.getSideRailWidth()); 1208 sideTieColorButton.setBackground(ltdOptions.getSideTieColor()); 1209 sideTieGapSpinner.setValue(ltdOptions.getSideTieGap()); 1210 sideTieLengthSpinner.setValue(ltdOptions.getSideTieLength()); 1211 sideTieWidthSpinner.setValue(ltdOptions.getSideTieWidth()); 1212 copyToCustom = true; 1213 } // setupControls 1214 1215 // used to prevent xxx.setValue's in setupControls from creating custom preset 1216 private boolean copyToCustom = true; 1217 1218 private void makeCustomPreset() { 1219 if (copyToCustom && !ltdOptions.getName().equals(customPresetName)) { 1220 ltdOptions = new LayoutTrackDrawingOptions(ltdOptions); 1221 ltdOptions.setName(customPresetName); 1222 if (!ltdoList.get(ltdoList.size() - 1).getName().equals(customPresetName)) { 1223 ltdoList.add(ltdOptions); 1224 presetsComboBox.addItem(ltdOptions.getName()); 1225 } 1226 presetsComboBox.setSelectedItem(ltdOptions.getName()); 1227 optionsPanel.setBorder(BorderFactory.createTitledBorder(customPresetName)); 1228 } 1229 } 1230 // define the presets 1231 1232 private void definePresets() { 1233 LayoutTrackDrawingOptions tempLTDO = new LayoutTrackDrawingOptions(classicPresetName); 1234 tempLTDO.setMainBallastColor(Color.BLACK); 1235 tempLTDO.setMainBallastWidth(0); 1236 tempLTDO.setMainBlockLineDashPercentageX10(0); 1237 tempLTDO.setMainBlockLineWidth(4); 1238 tempLTDO.setMainRailColor(Color.BLACK); 1239 tempLTDO.setMainRailCount(1); 1240 tempLTDO.setMainRailGap(0); 1241 tempLTDO.setMainRailWidth(2); 1242 tempLTDO.setMainTieColor(Color.BLACK); 1243 tempLTDO.setMainTieGap(0); 1244 tempLTDO.setMainTieLength(0); 1245 tempLTDO.setMainTieWidth(0); 1246 tempLTDO.setSideBallastColor(Color.BLACK); 1247 tempLTDO.setSideBallastWidth(0); 1248 tempLTDO.setSideBlockLineDashPercentageX10(0); 1249 tempLTDO.setSideBlockLineWidth(2); 1250 tempLTDO.setSideRailColor(Color.BLACK); 1251 tempLTDO.setSideRailCount(1); 1252 tempLTDO.setSideRailGap(0); 1253 tempLTDO.setSideRailWidth(1); 1254 tempLTDO.setSideTieColor(Color.BLACK); 1255 tempLTDO.setSideTieGap(0); 1256 tempLTDO.setSideTieLength(0); 1257 tempLTDO.setSideTieWidth(0); 1258 tempLTDO.setBlockDefaultColor(Color.GRAY); 1259 tempLTDO.setBlockOccupiedColor(Color.RED); 1260 tempLTDO.setBlockAlternativeColor(Color.WHITE); 1261 ltdoList.add(tempLTDO); 1262 1263 tempLTDO = new LayoutTrackDrawingOptions(draftingPresetName); 1264 tempLTDO.setMainBallastColor(Color.BLACK); 1265 tempLTDO.setMainBallastWidth(0); 1266 tempLTDO.setMainBlockLineDashPercentageX10(0); 1267 tempLTDO.setMainBlockLineWidth(4); 1268 tempLTDO.setMainRailColor(Color.BLACK); 1269 tempLTDO.setMainRailCount(2); 1270 tempLTDO.setMainRailGap(2); 1271 tempLTDO.setMainRailWidth(2); 1272 tempLTDO.setMainTieColor(Color.BLACK); 1273 tempLTDO.setMainTieGap(0); 1274 tempLTDO.setMainTieLength(0); 1275 tempLTDO.setMainTieWidth(0); 1276 tempLTDO.setSideBallastColor(Color.BLACK); 1277 tempLTDO.setSideBallastWidth(0); 1278 tempLTDO.setSideBlockLineDashPercentageX10(0); 1279 tempLTDO.setSideBlockLineWidth(4); 1280 tempLTDO.setSideRailColor(Color.BLACK); 1281 tempLTDO.setSideRailCount(2); 1282 tempLTDO.setSideRailGap(3); 1283 tempLTDO.setSideRailWidth(1); 1284 tempLTDO.setSideTieColor(Color.BLACK); 1285 tempLTDO.setSideTieGap(0); 1286 tempLTDO.setSideTieLength(0); 1287 tempLTDO.setSideTieWidth(0); 1288 tempLTDO.setBlockDefaultColor(Color.GRAY); 1289 tempLTDO.setBlockOccupiedColor(Color.RED); 1290 tempLTDO.setBlockAlternativeColor(Color.WHITE); 1291 ltdoList.add(tempLTDO); 1292 1293 tempLTDO = new LayoutTrackDrawingOptions(realisticPresetName); 1294 tempLTDO.setMainBallastColor(Color.decode("#A0A0A0")); 1295 tempLTDO.setMainBallastWidth(13); 1296 tempLTDO.setMainBlockLineDashPercentageX10(0); 1297 tempLTDO.setMainBlockLineWidth(2); 1298 tempLTDO.setMainRailColor(Color.decode("#C0C0C0")); 1299 tempLTDO.setMainRailCount(2); 1300 tempLTDO.setMainRailGap(3); 1301 tempLTDO.setMainRailWidth(2); 1302 tempLTDO.setMainTieColor(Color.decode("#E0E0E0")); 1303 tempLTDO.setMainTieGap(7); 1304 tempLTDO.setMainTieLength(11); 1305 tempLTDO.setMainTieWidth(1); 1306 tempLTDO.setSideBallastColor(Color.GRAY); 1307 tempLTDO.setSideBallastWidth(11); 1308 tempLTDO.setSideBlockLineDashPercentageX10(0); 1309 tempLTDO.setSideBlockLineWidth(2); 1310 tempLTDO.setSideRailColor(Color.decode("#D07060")); 1311 tempLTDO.setSideRailCount(2); 1312 tempLTDO.setSideRailGap(3); 1313 tempLTDO.setSideRailWidth(1); 1314 tempLTDO.setSideTieColor(Color.decode("#382018")); 1315 tempLTDO.setSideTieGap(6); 1316 tempLTDO.setSideTieLength(9); 1317 tempLTDO.setSideTieWidth(3); 1318 tempLTDO.setBlockDefaultColor(Color.GRAY); 1319 tempLTDO.setBlockOccupiedColor(Color.RED); 1320 tempLTDO.setBlockAlternativeColor(Color.WHITE); 1321 ltdoList.add(tempLTDO); 1322 1323 tempLTDO = new LayoutTrackDrawingOptions(realisticOhPresetName); 1324 tempLTDO.setMainBallastColor(Color.decode("#A0A0A0")); 1325 tempLTDO.setMainBallastWidth(26); 1326 tempLTDO.setMainBlockLineDashPercentageX10(0); 1327 tempLTDO.setMainBlockLineWidth(4); 1328 tempLTDO.setMainRailColor(Color.LIGHT_GRAY); 1329 tempLTDO.setMainRailCount(3); 1330 tempLTDO.setMainRailGap(6); 1331 tempLTDO.setMainRailWidth(2); 1332 tempLTDO.setMainTieColor(Color.decode("#E0E0E0")); 1333 tempLTDO.setMainTieGap(14); 1334 tempLTDO.setMainTieLength(22); 1335 tempLTDO.setMainTieWidth(2); 1336 tempLTDO.setSideBallastColor(Color.GRAY); 1337 tempLTDO.setSideBallastWidth(22); 1338 tempLTDO.setSideBlockLineDashPercentageX10(0); 1339 tempLTDO.setSideBlockLineWidth(4); 1340 tempLTDO.setSideRailColor(Color.decode("#D07060")); 1341 tempLTDO.setSideRailCount(3); 1342 tempLTDO.setSideRailGap(6); 1343 tempLTDO.setSideRailWidth(2); 1344 tempLTDO.setSideTieColor(Color.decode("#382018")); 1345 tempLTDO.setSideTieGap(12); 1346 tempLTDO.setSideTieLength(18); 1347 tempLTDO.setSideTieWidth(6); 1348 tempLTDO.setBlockDefaultColor(Color.GRAY); 1349 tempLTDO.setBlockOccupiedColor(Color.RED); 1350 tempLTDO.setBlockAlternativeColor(Color.WHITE); 1351 ltdoList.add(tempLTDO); 1352 1353 tempLTDO = new LayoutTrackDrawingOptions(british70sPresetName); 1354 tempLTDO.setMainBallastColor(Color.BLACK); 1355 tempLTDO.setMainBallastWidth(5); 1356 tempLTDO.setMainBlockLineDashPercentageX10(5); 1357 tempLTDO.setMainBlockLineWidth(4); 1358 tempLTDO.setMainRailColor(Color.BLACK); 1359 tempLTDO.setMainRailCount(0); 1360 tempLTDO.setMainRailGap(0); 1361 tempLTDO.setMainRailWidth(2); 1362 tempLTDO.setMainTieColor(Color.BLACK); 1363 tempLTDO.setMainTieGap(0); 1364 tempLTDO.setMainTieLength(0); 1365 tempLTDO.setMainTieWidth(0); 1366 tempLTDO.setSideBallastColor(Color.BLACK); 1367 tempLTDO.setSideBallastWidth(3); 1368 tempLTDO.setSideBlockLineDashPercentageX10(5); 1369 tempLTDO.setSideBlockLineWidth(2); 1370 tempLTDO.setSideRailColor(Color.BLACK); 1371 tempLTDO.setSideRailCount(0); 1372 tempLTDO.setSideRailGap(0); 1373 tempLTDO.setSideRailWidth(1); 1374 tempLTDO.setSideTieColor(Color.BLACK); 1375 tempLTDO.setSideTieGap(0); 1376 tempLTDO.setSideTieLength(0); 1377 tempLTDO.setSideTieWidth(0); 1378 tempLTDO.setBlockDefaultColor(Color.GRAY); 1379 tempLTDO.setBlockOccupiedColor(Color.RED); 1380 tempLTDO.setBlockAlternativeColor(Color.WHITE); 1381 ltdoList.add(tempLTDO); 1382 1383 tempLTDO = new LayoutTrackDrawingOptions(csdazd71PresetName); 1384 tempLTDO.setMainBallastColor(Color.decode("#000000")); 1385 tempLTDO.setMainBallastWidth(0); 1386 tempLTDO.setMainBlockLineDashPercentageX10(6); 1387 tempLTDO.setMainBlockLineWidth(6); 1388 tempLTDO.setMainRailColor(Color.decode("#000000")); 1389 tempLTDO.setMainRailCount(1); 1390 tempLTDO.setMainRailGap(0); 1391 tempLTDO.setMainRailWidth(10); 1392 tempLTDO.setMainTieColor(Color.decode("#000000")); 1393 tempLTDO.setMainTieGap(0); 1394 tempLTDO.setMainTieLength(0); 1395 tempLTDO.setMainTieWidth(0); 1396 tempLTDO.setSideBallastColor(Color.decode("#000000")); 1397 tempLTDO.setSideBallastWidth(0); 1398 tempLTDO.setSideBlockLineDashPercentageX10(6); 1399 tempLTDO.setSideBlockLineWidth(6); 1400 tempLTDO.setSideRailColor(Color.decode("#000000")); 1401 tempLTDO.setSideRailCount(1); 1402 tempLTDO.setSideRailGap(0); 1403 tempLTDO.setSideRailWidth(10); 1404 tempLTDO.setSideTieColor(Color.decode("#000000")); 1405 tempLTDO.setSideTieGap(0); 1406 tempLTDO.setSideTieLength(0); 1407 tempLTDO.setSideTieWidth(0); 1408 tempLTDO.setBlockDefaultColor(Color.decode("#606060")); 1409 tempLTDO.setBlockOccupiedColor(Color.decode("#E00000")); 1410 tempLTDO.setBlockAlternativeColor(Color.decode("#FFFFE0")); 1411 ltdoList.add(tempLTDO); 1412 1413 ltdoList.add(ltdOptions); 1414 1415 presetsComboBox.removeAllItems(); 1416 ltdoList.forEach((ltdo) -> presetsComboBox.addItem(ltdo.getName())); 1417 presetsComboBox.setSelectedItem(leLTDOptions.getName()); 1418 } // definePresets 1419 1420 /*===========================*\ 1421 |* local (private) variables *| 1422 \*===========================*/ 1423 1424 // Variables declaration - do not modify//GEN-BEGIN:variables 1425 private javax.swing.JButton applyButton; 1426 1427 private javax.swing.JButton blockDefaultColorButton; 1428 private javax.swing.JButton blockOccupiedColorButton; 1429 private javax.swing.JButton blockAlternativeColorButton; 1430 1431 private javax.swing.JLabel ballastWidthLabel; 1432 private javax.swing.JLabel blockLineDashPercentageX10Label; 1433 private javax.swing.JLabel blockLineWidthLabel; 1434 private javax.swing.JButton cancelButton; 1435 private javax.swing.JPanel jPanelButtons; 1436 private javax.swing.JButton mainBallastColorButton; 1437 private javax.swing.JSpinner mainBallastWidthSpinner; 1438 private javax.swing.JSpinner mainBlockLineDashPercentageX10Spinner; 1439 private javax.swing.JSpinner mainBlockLineWidthSpinner; 1440 private javax.swing.JButton mainRailColorButton; 1441 private javax.swing.JSpinner mainRailCountSpinner; 1442 private javax.swing.JSpinner mainRailGapSpinner; 1443 private javax.swing.JSpinner mainRailWidthSpinner; 1444 private javax.swing.JButton mainTieColorButton; 1445 private javax.swing.JSpinner mainTieGapSpinner; 1446 private javax.swing.JSpinner mainTieLengthSpinner; 1447 private javax.swing.JSpinner mainTieWidthSpinner; 1448 private javax.swing.JLabel mainlineLabel; 1449 private javax.swing.JButton okButton; 1450 private javax.swing.JLabel optionLabel; 1451 private javax.swing.JPanel optionsPanel; 1452 private javax.swing.JComboBox<String> presetsComboBox; 1453 private javax.swing.JLabel presetsLabel; 1454 private javax.swing.JLabel railCountLabel; 1455 private javax.swing.JLabel railGapLabel; 1456 private javax.swing.JLabel railWidthLabel; 1457 private javax.swing.JButton sideBallastColorButton; 1458 private javax.swing.JSpinner sideBallastWidthSpinner; 1459 private javax.swing.JSpinner sideBlockLineDashPercentageX10Spinner; 1460 private javax.swing.JSpinner sideBlockLineWidthSpinner; 1461 private javax.swing.JButton sideRailColorButton; 1462 private javax.swing.JSpinner sideRailCountSpinner; 1463 private javax.swing.JSpinner sideRailGapSpinner; 1464 private javax.swing.JSpinner sideRailWidthSpinner; 1465 private javax.swing.JButton sideTieColorButton; 1466 private javax.swing.JSpinner sideTieGapSpinner; 1467 private javax.swing.JSpinner sideTieLengthSpinner; 1468 private javax.swing.JSpinner sideTieWidthSpinner; 1469 private javax.swing.JLabel sidelineLabel; 1470 private javax.swing.JLabel tieGapLabel; 1471 private javax.swing.JLabel tieLengthLabel; 1472 private javax.swing.JLabel tieWidthLabel; 1473 // End of variables declaration//GEN-END:variables 1474 1475 /*====================*\ 1476 |* initialize logging *| 1477 \*====================*/ 1478 private final static Logger log 1479 = LoggerFactory.getLogger(LayoutTrackDrawingOptionsDialog.class); 1480}