Changeset 3104
- Timestamp:
- 07/16/08 15:32:14 (5 years ago)
- Location:
- PP/branches/leap-second-dev-branch/jungle/src/org/trinet
- Files:
-
- 7 edited
-
jasi/JasiPropertyList.java (modified) (1 diff)
-
jiggle/DPcatalog.java (modified) (12 diffs)
-
jiggle/DPtraceColors.java (modified) (6 diffs)
-
jiggle/Jiggle.java (modified) (2 diffs)
-
jiggle/PhaseDialog.java (modified) (7 diffs)
-
jiggle/PickingPanel.java (modified) (7 diffs)
-
jiggle/PreferencesDialog.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jasi/JasiPropertyList.java
r3032 r3104 115 115 116 116 if (readAuxFile) { 117 // Auxillary file can override properties already set in parent, since last read property trumps previously set property. 117 118 String file = getUserFileNameFromProperty("auxPropFile"); 118 119 if (file != null) { 119 System.out.println(getClass().getName() + " Loading auxPropFile properties from: " + file);120 System.out.println(getClass().getName() + " Loading properties from auxPropFile : " + file); 120 121 if (! readPropertiesFile(file) ) { 121 System.err.println(" ERROR: unable to load auxPropFile properties from: " + file);122 System.err.println(" ERROR: unable to load properties from auxPropFile : " + file); 122 123 return false; 123 124 } 124 125 } 126 /* Below ok for input, but what about saving of GUI changed properties, they would all go into one file. 127 String [] propfileTags = getStringArray("auxPropFileTags"); 128 if (propfileTags != null && propfileTags.length > 0) { 129 for (int idx=0; idx < propfileTags.length; idx++) { 130 file = getUserFileNameFromProperty("auxPropFile."+propfileTags[i]); 131 if (file != null) { 132 System.out.println(getClass().getName() + " Loading properties from auxPropFile." + propfileTags[i] + " : " + file); 133 if (! readPropertiesFile(file) ) { 134 System.err.println(" ERROR: unable to load properties from auxPropFile." + propfileTags[i] + " : " + file); 135 return false; 136 } 137 } 138 } 139 } 140 */ 125 141 } 126 142 -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/DPcatalog.java
r3065 r3104 9 9 import javax.swing.event.ChangeListener; 10 10 11 import org.trinet.jasi.ActiveList; 11 12 import org.trinet.util.StringList; 12 13 import org.trinet.util.graphics.IconImage; … … 16 17 */ 17 18 public class DPcatalog extends JPanel { 19 20 private JiggleProperties newProps; // new properties as changed by this dialog 21 private CatalogColumnChooserPanel columnChooserPanel = null; 22 private CatalogRowColorChooserPanel rowColorChooserPanel = null; 23 24 protected boolean colorChanged = false; 25 26 public DPcatalog(JiggleProperties props) { 27 newProps = props; 28 columnChooserPanel = new CatalogColumnChooserPanel(); 29 rowColorChooserPanel = new CatalogRowColorChooserPanel(); 30 try { 31 initGraphics(); 32 } 33 catch(Exception e) { 34 e.printStackTrace(); 35 } 36 } 37 38 private void initGraphics() { 39 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 40 columnChooserPanel.initGraphics(); 41 this.add(columnChooserPanel); 42 rowColorChooserPanel.initGraphics(); 43 this.add(rowColorChooserPanel); 44 } 45 46 public void setCatalogColumnListProperty() { 47 ArrayList aList = columnChooserPanel.getChoosen(); 48 StringBuffer sb = new StringBuffer(512); 49 for (int idx = 0; idx < aList.size(); idx++) sb.append((String)aList.get(idx)).append(" "); 50 newProps.setProperty("catalogColumnList", sb.toString()); 51 } 52 53 public void setColorProperties() { 54 if (rowColorChooserPanel != null) rowColorChooserPanel.setColorProperties(); 55 } 56 18 57 19 58 private static final String [] SORTED_CAT_COL_NAMES = { … … 33 72 }; 34 73 35 36 private static final HashMap toolTipMap = new HashMap(37); 37 38 private JiggleProperties newProps; // new properties as changed by this dialog 39 private ItemChooserPanel icp = new ItemChooserPanel(); 40 41 private boolean colorChanged = false; 42 43 public DPcatalog(JiggleProperties props) { 44 newProps = props; 45 for (int idx = 0; idx<SORTED_CAT_COL_NAMES.length; idx++) { 46 toolTipMap.put(SORTED_CAT_COL_NAMES [idx],CAT_COL_NAME_TIPS [idx]); 47 } 48 49 try { 50 initGraphics(); 51 } 52 catch(Exception e) { 53 e.printStackTrace(); 54 } 55 } 56 57 private void initGraphics() { 58 setBorder(BorderFactory.createTitledBorder("Catalog columns")); 59 icp.setAll(new StringList(SORTED_CAT_COL_NAMES).getList()); 60 java.util.List list = newProps.getStringList("catalogColumnList").getList(); 61 if (list == null || list.isEmpty()) list = new StringList(SORTED_CAT_COL_NAMES).getList(); 62 icp.setChoosen(list); 63 icp.initGraphics(); 64 this.add(icp); 65 } 66 67 public void setCatalogColumnList() { 68 ArrayList aList = icp.getChoosen(); 69 StringBuffer sb = new StringBuffer(512); 70 for (int idx = 0; idx < aList.size(); idx++) sb.append((String)aList.get(idx)).append(" "); 71 newProps.setProperty("catalogColumnList",sb.toString()); 72 } 73 74 class ItemChooserPanel extends JPanel { 74 class CatalogColumnChooserPanel extends JPanel { 75 76 private final HashMap toolTipMap = new HashMap(37); 77 75 78 private java.util.List allItems = null; 76 79 private java.util.List rejectItems = null;; … … 78 81 private javax.swing.JList chooseList = null; 79 82 80 public ItemChooserPanel() { } 81 82 public ItemChooserPanel(java.util.List all) { 83 setAll(all); 83 public CatalogColumnChooserPanel() { 84 setBorder(BorderFactory.createTitledBorder("Catalog columns")); 85 86 for (int idx = 0; idx<SORTED_CAT_COL_NAMES.length; idx++) { 87 toolTipMap.put(SORTED_CAT_COL_NAMES [idx],CAT_COL_NAME_TIPS [idx]); 88 } 89 90 setAll(new StringList(SORTED_CAT_COL_NAMES).getList()); 91 92 java.util.List list = newProps.getStringList("catalogColumnList").getList(); 93 if (list == null || list.isEmpty()) list = new StringList(SORTED_CAT_COL_NAMES).getList(); 94 setChoosen(list); 84 95 } 85 96 … … 116 127 117 128 public void initGraphics() { 118 setLayout(new BorderLayout());119 129 Box hbox = Box.createHorizontalBox(); 120 130 hbox.setBorder(BorderFactory.createTitledBorder("Catalog Table Column Arrangement")); … … 216 226 vbox.add(jb); 217 227 hbox.add(vbox); 218 219 this.add(hbox, BorderLayout.NORTH); 220 221 vbox = Box.createVerticalBox(); 222 vbox.setBorder(BorderFactory.createTitledBorder("Catalog Row Color Selection")); 223 224 hbox = Box.createHorizontalBox(); 225 226 ButtonGroup bg = new ButtonGroup(); 227 hbox = Box.createHorizontalBox(); 228 String str = newProps.getProperty("colorCatalogByType", "0"); 229 hbox.add(new JLabel("Color catalog by ")); 230 ActionListener al3 = new CatalogColorCategoryAction(); 231 JRadioButton jrb = new JRadioButton("Event type"); 232 jrb.setSelected(str.equals("1")); 233 jrb.addActionListener(al3); 234 bg.add(jrb); 235 hbox.add(jrb); 236 jrb = new JRadioButton("Processing state"); 237 jrb.setSelected(str.equals("2")); 238 jrb.addActionListener(al3); 239 bg.add(jrb); 240 hbox.add(jrb); 241 jrb = new JRadioButton("Uniform background"); 242 jrb.setSelected(str.equals("0")); 243 jrb.addActionListener(al3); 244 bg.add(jrb); 245 hbox.add(jrb); 246 hbox.setAlignmentX(Component.LEFT_ALIGNMENT); 247 vbox.add(hbox); 248 249 getColors(); 250 251 JPanel vbox2 = new JPanel(new GridLayout(0,2)); // Box.createVerticalBox(); 252 vbox2.setBorder(BorderFactory.createTitledBorder("Uniform Background")); 253 makeColorPropertyComponent(vbox2, "color.catalog.uniform", colorBck); 254 vbox2.setAlignmentX(Component.LEFT_ALIGNMENT); 255 vbox.add(vbox2); 256 257 JPanel vbox3 = new JPanel(new GridLayout(0,2)); // Box.createVerticalBox(); 258 vbox3.setBorder(BorderFactory.createTitledBorder("Event Type")); 259 makeColorPropertyComponent(vbox3, "color.catalog.local", colorLoc); 260 makeColorPropertyComponent(vbox3, "color.catalog.quarry", colorQry); 261 makeColorPropertyComponent(vbox3, "color.catalog.teleseism", colorTel); 262 makeColorPropertyComponent(vbox3, "color.catalog.regional", colorReg); 263 makeColorPropertyComponent(vbox3, "color.catalog.trigger", colorTrg); 264 makeColorPropertyComponent(vbox3, "color.catalog.sonic", colorSon); 265 vbox3.setAlignmentX(Component.LEFT_ALIGNMENT); 266 vbox.add(vbox3); 267 268 JPanel vbox4 = new JPanel(new GridLayout(0,2)); // Box.createVerticalBox(); 269 vbox4.setBorder(BorderFactory.createTitledBorder("Processing State")); 270 makeColorPropertyComponent(vbox4, "color.catalog.A", colorA); 271 makeColorPropertyComponent(vbox4, "color.catalog.H", colorH); 272 makeColorPropertyComponent(vbox4, "color.catalog.F", colorF); 273 vbox4.setAlignmentX(Component.LEFT_ALIGNMENT); 274 vbox.add(vbox4); 275 276 this.add(vbox, BorderLayout.SOUTH); 277 278 } 279 280 } 281 282 private JButton makeButton(String labelStr, String tooltip, String imageStr) { 228 this.add(hbox); 229 } 230 231 232 private JButton makeButton(String labelStr, String tooltip, String imageStr) { 283 233 Image image = IconImage.getImage(imageStr); 284 234 JButton btn = null; 285 if (image == null) { // handle situation when .gif file can't be found235 if (image == null) { // handle situation when .gif file can't be found 286 236 btn = new JButton(labelStr); 287 237 } else { … … 293 243 btn.setToolTipText(tooltip); 294 244 return btn; 295 } 296 297 298 class MyToolTipListCellRenderer extends JLabel implements ListCellRenderer { 299 public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 245 } 246 247 class MyToolTipListCellRenderer extends JLabel implements ListCellRenderer { 248 public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 300 249 String s = value.toString(); 301 250 setText(s); … … 314 263 return this; 315 264 } 316 } 265 } 266 } 267 268 class CatalogRowColorChooserPanel extends JPanel { 269 270 private Color colorBck = new Color(Integer.parseInt("FFFFB2",16)); // pale yellow 271 private Color colorLoc = new Color(Integer.parseInt("8BFFEE",16)); // blue 272 private Color colorQry = new Color(Integer.parseInt("899CFE",16)); // dk blue 273 private Color colorTel = new Color(Integer.parseInt("89FF8A",16)); // green 274 private Color colorReg = new Color(Integer.parseInt("FF9BFC",16)); // purple 275 private Color colorTrg = new Color(Integer.parseInt("FFCCC6",16)); // pink 276 private Color colorSon = new Color(Integer.parseInt("FFD0D0",16)); // creamy orange 277 278 private Color colorA = new Color(Integer.parseInt("8BFFEE",16)); // blue 279 private Color colorH = new Color(Integer.parseInt("899CFE",16)); // dk blue 280 private Color colorF = new Color(Integer.parseInt("89FF8A",16)); // green 281 282 private ActiveList catalogButtonList = new ActiveList(); 283 private MyColorButton lastButton = null; 284 285 private void initGraphics() { 286 287 Box catColorBox = Box.createVerticalBox(); 288 catColorBox.setBorder(BorderFactory.createTitledBorder("Catalog Row Color Selection")); 289 catColorBox.setAlignmentX(Component.LEFT_ALIGNMENT); 290 291 Box hbox = Box.createHorizontalBox(); 292 293 ButtonGroup bg = new ButtonGroup(); 294 hbox = Box.createHorizontalBox(); 295 String str = newProps.getProperty("colorCatalogByType", "0"); 296 hbox.add(new JLabel("Color catalog by ")); 297 ActionListener al3 = new CatalogColorCategoryAction(); 298 JRadioButton jrb = new JRadioButton("Event type"); 299 jrb.setSelected(str.equals("1")); 300 jrb.addActionListener(al3); 301 bg.add(jrb); 302 hbox.add(jrb); 303 jrb = new JRadioButton("Processing state"); 304 jrb.setSelected(str.equals("2")); 305 jrb.addActionListener(al3); 306 bg.add(jrb); 307 hbox.add(jrb); 308 jrb = new JRadioButton("Uniform background"); 309 jrb.setSelected(str.equals("0")); 310 jrb.addActionListener(al3); 311 bg.add(jrb); 312 hbox.add(jrb); 313 hbox.setAlignmentX(Component.LEFT_ALIGNMENT); 314 catColorBox.add(hbox); 315 316 setupColors(); // sets value of class instance field colors used below, like colorBck 317 318 Box vbox2 = Box.createVerticalBox(); 319 vbox2.setBorder(BorderFactory.createTitledBorder("Uniform Background")); 320 makeColorPropertyComponent(vbox2, "color.catalog.uniform", colorBck); 321 catColorBox.add(vbox2); 322 323 final Box vbox3 = Box.createVerticalBox(); 324 vbox3.setBorder(BorderFactory.createTitledBorder("Event Type")); 325 addEventTypeColorButtons(vbox3); 326 JButton jb = new JButton("Add new event type"); 327 jb.setToolTipText("Press to add new event type color"); 328 jb.addActionListener(new ActionListener() { 329 public void actionPerformed(ActionEvent evt) { 330 addNewEventTypeButton(vbox3); 331 } 332 }); 333 vbox3.add(jb); 334 catColorBox.add(vbox3); 335 336 Box vbox4 = Box.createVerticalBox(); 337 vbox4.setBorder(BorderFactory.createTitledBorder("Processing State")); 338 makeColorPropertyComponent(vbox4, "color.catalog.A", colorA); 339 makeColorPropertyComponent(vbox4, "color.catalog.H", colorH); 340 makeColorPropertyComponent(vbox4, "color.catalog.F", colorF); 341 catColorBox.add(vbox4); 342 this.add(catColorBox); 343 } 317 344 318 345 private class CatalogColorCategoryAction implements ActionListener { … … 326 353 value = "2"; 327 354 } 355 colorChanged = true; // assume changed, though user may have just toggled back to original value 328 356 newProps.setProperty("colorCatalogByType",value); 329 357 } 330 358 } 331 359 332 private void getColors() { 360 protected void setupColors() { 361 333 362 Color c = newProps.getColor("color.catalog.uniform"); 334 363 if (c != null) colorBck = c; 364 else newProps.setProperty("color.catalog.uniform", colorBck); 365 335 366 c = newProps.getColor("color.catalog.local"); 336 367 if (c != null) colorLoc = c; 368 else newProps.setProperty("color.catalog.local", colorLoc); 369 337 370 c = newProps.getColor("color.catalog.quarry"); 338 371 if (c != null) colorQry = c; 372 else newProps.setProperty("color.catalog.quarry", colorQry); 373 339 374 c = newProps.getColor("color.catalog.regional"); 340 375 if (c != null) colorReg = c; 376 else newProps.setProperty("color.catalog.regional", colorReg); 377 341 378 c = newProps.getColor("color.catalog.teleseism"); 342 379 if (c != null) colorTel = c; 380 else newProps.setProperty("color.catalog.teleseism", colorTel); 381 343 382 c = newProps.getColor("color.catalog.trigger"); 344 383 if (c != null) colorTrg = c; 384 else newProps.setProperty("color.catalog.trigger", colorTrg); 385 345 386 c = newProps.getColor("color.catalog.sonic"); 346 387 if (c != null) colorSon = c; 388 else newProps.setProperty("color.catalog.sonic", colorSon); 389 347 390 c = newProps.getColor("color.catalog.A"); 348 391 if (c != null) colorA = c; 392 else newProps.setProperty("color.catalog.A", colorA); 393 349 394 c = newProps.getColor("color.catalog.H"); 350 395 if (c != null) colorH = c; 396 else newProps.setProperty("color.catalog.H", colorH); 397 351 398 c = newProps.getColor("color.catalog.F"); 352 399 if (c != null) colorF = c; 353 } 354 355 private void makeColorPropertyComponent(JComponent hbox, final String label, final Color color) { 356 //JPanel hbox = new JPanel(); // Box.createHorizontalBox(); 357 //hbox.setLayout(new GridLayout(0,2)); 400 else newProps.setProperty("color.catalog.F", colorF); 401 } 402 403 protected void setColorProperties() { 404 JButton jb = null; 405 for (int idx = 0; idx < catalogButtonList.size(); idx++) { 406 jb = (JButton) catalogButtonList.get(idx); 407 newProps.setProperty(jb.getActionCommand(), jb.getBackground()); 408 } 409 } 410 411 protected void setDefaultColorProperties() { 412 newProps.setProperty("color.catalog.uniform", colorBck); 413 newProps.setProperty("color.catalog.local", colorLoc); 414 newProps.setProperty("color.catalog.quarry", colorQry); 415 newProps.setProperty("color.catalog.regional", colorReg); 416 newProps.setProperty("color.catalog.teleseism", colorTel); 417 newProps.setProperty("color.catalog.trigger", colorTrg); 418 newProps.setProperty("color.catalog.sonic", colorSon); 419 newProps.setProperty("color.catalog.A", colorA); 420 newProps.setProperty("color.catalog.H", colorH); 421 newProps.setProperty("color.catalog.F", colorF); 422 } 423 424 private class MyColorButton extends JButton { 425 public boolean equals(Object obj) { 426 if (obj instanceof MyColorButton) { 427 return getActionCommand().equals(((MyColorButton)obj).getActionCommand()); 428 } 429 return false; 430 } 431 } 432 433 private void addNewEventTypeButton(JComponent comp) { 434 String input = 435 JOptionPane.showInputDialog(getTopLevelAncestor(), 436 "Enter new event type", 437 "New Event Type Color", 438 JOptionPane.PLAIN_MESSAGE); 439 440 if (input != null && input.length() > 1) { // processing state are single letters, so skip 441 String label = "color.catalog."+ input; 442 MyColorButton jb = null; 443 boolean inList = false; 444 for (int idx = 0; idx < catalogButtonList.size(); idx++) { 445 jb = (MyColorButton) catalogButtonList.get(idx); 446 if (jb.getActionCommand().equals(label)) { 447 inList = true; 448 break; 449 } 450 } 451 452 if (inList) jb.doClick(); 453 else { 454 makeColorPropertyComponent(comp, label, Color.white); 455 comp.revalidate(); 456 if (lastButton != null) lastButton.doClick(); 457 } 458 } 459 } 460 461 private JComponent makeColorPropertyComponent(JComponent comp, final String label, final Color color) { 462 Box hbox = Box.createHorizontalBox(); 463 hbox.add(makeColorButtonLabel(label)); 464 hbox.add(makeColorButton(label, color)); 465 hbox.setAlignmentX(Component.LEFT_ALIGNMENT); 466 comp.add(hbox); 467 return comp; 468 } 469 470 private JLabel makeColorButtonLabel(String label) { 358 471 int idx = label.lastIndexOf('.'); 359 final JLabel jlbl = new JLabel(label.substring(idx+1)); 360 jlbl.setAlignmentX(Component.LEFT_ALIGNMENT); 361 hbox.add(jlbl); 362 363 final JButton jb = new JButton(); 364 jb.setAlignmentX(Component.LEFT_ALIGNMENT); 472 JLabel jlbl = new JLabel(label.substring(idx+1)); 473 jlbl.setPreferredSize(new Dimension(100,16)); 474 jlbl.setMaximumSize(new Dimension(100,16)); 475 jlbl.setToolTipText("Row type, press color to change its color"); 476 return jlbl; 477 } 478 479 private MyColorButton makeColorButton(final String label, final Color color) { 480 final MyColorButton jb = new MyColorButton(); 481 jb.setActionCommand(label); 365 482 jb.setBackground(color); 366 jb.setActionCommand(label); 483 jb.setToolTipText(Integer.toHexString(color.getRGB())); 484 367 485 jb.addActionListener( new ActionListener() { 368 486 public void actionPerformed(ActionEvent evt) { … … 376 494 public void stateChanged(ChangeEvent evt) { 377 495 MyJLabel.this.setBackground(jcc.getSelectionModel().getSelectedColor()); 496 //MyJLabel.this.setForeground(jcc.getSelectionModel().getSelectedColor()); 378 497 MyJLabel.this.repaint(); 379 498 } … … 382 501 JPanel jp = new JPanel(); 383 502 jp.setBackground(Color.white); 384 jp.setBorder(BorderFactory.createTitledBorder( "New Catalog Row Color for " + jlbl.getText()));503 jp.setBorder(BorderFactory.createTitledBorder(jb.getActionCommand())); 385 504 jlbl2.setForeground(Color.black); 386 505 jlbl2.setBackground(color); … … 410 529 } 411 530 catch(HeadlessException ex) {} 412 413 531 } 414 532 }); 415 533 416 hbox.add(jb); 417 hbox.setAlignmentX(Component.LEFT_ALIGNMENT); 418 419 //return hbox; 420 421 } 422 423 private void setColorProperties() { 424 newProps.setProperty("color.catalog.uniform", colorBck); 425 newProps.setProperty("color.catalog.local", colorLoc); 426 newProps.setProperty("color.catalog.quarry", colorQry); 427 newProps.setProperty("color.catalog.regional", colorReg); 428 newProps.setProperty("color.catalog.teleseism", colorTel); 429 newProps.setProperty("color.catalog.trigger", colorTrg); 430 newProps.setProperty("color.catalog.sonic", colorSon); 431 newProps.setProperty("color.catalog.A", colorA); 432 newProps.setProperty("color.catalog.H", colorH); 433 newProps.setProperty("color.catalog.F", colorF); 434 } 435 436 private Color colorBck = new Color(Integer.parseInt("FFFFB2",16)); // pale yellow 437 private Color colorLoc = new Color(Integer.parseInt("8BFFEE",16)); // blue 438 private Color colorQry = new Color(Integer.parseInt("899CFE",16)); // dk blue 439 private Color colorTel = new Color(Integer.parseInt("89FF8A",16)); // green 440 private Color colorReg = new Color(Integer.parseInt("FF9BFC",16)); // purple 441 private Color colorTrg = new Color(Integer.parseInt("FFCCC6",16)); // pink 442 private Color colorSon = new Color(Integer.parseInt("FFD0D0",16)); // creamy orange 443 private Color colorA = new Color(Integer.parseInt("8BFFEE",16)); // blue 444 private Color colorH = new Color(Integer.parseInt("899CFE",16)); // dk blue 445 private Color colorF = new Color(Integer.parseInt("89FF8A",16)); // green 446 447 } 534 lastButton = jb; 535 catalogButtonList.addOrReplace(jb); 536 537 return jb; 538 } 539 540 private void addEventTypeColorButtons(JComponent comp) { 541 int idx = -1; 542 String key = null; 543 catalogButtonList.clear(); 544 for (Enumeration e = newProps.keys(); e.hasMoreElements();) { // alpha sorted order key 545 key = (String) e.nextElement(); 546 if (key.equals("color.catalog.uniform")) continue; 547 idx = key.indexOf("color.catalog"); 548 // assumes a single character final key element is a processing state type (A, H, F) so skip it 549 if ( idx >= 0 && (key.lastIndexOf('.') != key.length()-2) ) { 550 makeColorPropertyComponent(comp, key, newProps.getColor(key)); // getColor() returns null if unparseable 551 } 552 } 553 } 554 555 } // CatalogRowColorChooserPanel 556 557 } // DPcatalog -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/DPtraceColors.java
r3032 r3104 1 1 package org.trinet.jiggle; 2 2 3 import java.awt.BorderLayout; 3 4 import java.awt.Color; 4 5 import java.awt.Component; 5 6 import java.awt.Dimension; 6 import java.awt.GridLayout;7 7 import java.awt.HeadlessException; 8 8 import java.awt.event.ActionEvent; … … 13 13 import javax.swing.event.ChangeListener; 14 14 15 import org.trinet.jasi.ActiveList; 16 15 17 /** 16 18 * Panel for insertion into dialog box to edit waveform seedchan trace colors. … … 20 22 private JiggleProperties newProps = null; 21 23 22 private ArrayList jbList = new ArrayList(); 24 private ActiveList jbList = new ActiveList(); 25 26 private Box vbox = null; 27 28 private MyColorButton lastButton = null; 23 29 24 30 protected boolean colorChanged = false; … … 38 44 39 45 private void initGraphics() { 40 Box vbox = Box.createVerticalBox(); 46 47 JButton jb = new JButton("Add new seedchan type"); 48 jb.setToolTipText("Press to add new seedchan type color"); 49 jb.addActionListener(new ActionListener() { 50 public void actionPerformed(ActionEvent evt) { 51 addNewSeedchanButton(); 52 } 53 }); 54 55 vbox = Box.createVerticalBox(); 41 56 vbox.setBorder(BorderFactory.createTitledBorder("Waveform Seedchan Color")); 57 vbox.add(jb); 42 58 addColorButtons(vbox); 43 //vbox.setPreferredSize(new Dimension(300,200));44 59 this.add(vbox); 45 60 } 46 61 47 62 private class MyColorButton extends JButton { 63 public boolean equals(Object obj) { 64 if (obj instanceof MyColorButton) { 65 return getActionCommand().equals(((MyColorButton)obj).getActionCommand()); 66 } 67 return false; 68 } 69 } 70 71 private void addNewSeedchanButton() { 72 String input = 73 JOptionPane.showInputDialog(getTopLevelAncestor(), 74 "Enter first 2 letters of seedchan code", 75 "New Seedchan Code Color", 76 JOptionPane.PLAIN_MESSAGE); 77 78 if (input != null && input.length() > 1) { 79 String label = "color.seedchan."+ input.substring(0,2); 80 MyColorButton jb = null; 81 boolean inList = false; 82 for (int idx = 0; idx < jbList.size(); idx++) { 83 jb = (MyColorButton) jbList.get(idx); 84 if (jb.getActionCommand().equals(label)) { 85 inList = true; 86 break; 87 } 88 } 89 90 if (inList) jb.doClick(); 91 else { 92 vbox.add(makeColorPropertyComponent(label, Color.white)); 93 vbox.revalidate(); 94 if (lastButton != null) lastButton.doClick(); 95 } 96 } 97 } 98 48 99 private JComponent makeColorPropertyComponent(final String label, final Color color) { 49 JPanel comp = new JPanel(new GridLayout(0,2)); 50 comp.setAlignmentX(Component.RIGHT_ALIGNMENT); 100 Box comp = Box.createHorizontalBox(); 101 comp.add(makeColorButtonLabel(label)); 102 comp.add(makeColorButton(label, color)); 103 comp.setAlignmentX(Component.LEFT_ALIGNMENT); 104 return comp; 105 } 106 107 private JLabel makeColorButtonLabel(String label) { 51 108 int idx = label.lastIndexOf('.'); 52 finalJLabel jlbl = new JLabel(label.substring(idx+1));109 JLabel jlbl = new JLabel(label.substring(idx+1)); 53 110 jlbl.setPreferredSize(new Dimension(100,16)); 54 111 jlbl.setMaximumSize(new Dimension(100,16)); 55 jlbl.setAlignmentX(Component.RIGHT_ALIGNMENT); 56 jlbl.setToolTipText("First 2 letters of seedchan"); 57 comp.add(jlbl); 58 59 final JButton jb = new JButton(); 60 jb.setAlignmentX(Component.RIGHT_ALIGNMENT); 112 jlbl.setToolTipText("First 2 letters of seedchan, press color to change its color"); 113 return jlbl; 114 } 115 116 117 // 118 private MyColorButton makeColorButton(final String label, final Color color) { 119 final MyColorButton jb = new MyColorButton(); 120 jb.setActionCommand(label); 61 121 jb.setBackground(color); 62 122 jb.setToolTipText(Integer.toHexString(color.getRGB())); 63 jb.setActionCommand(label);64 123 jb.addActionListener( new ActionListener() { 65 124 public void actionPerformed(ActionEvent evt) { … … 80 139 JPanel jp = new JPanel(); 81 140 //jp.setBackground(Color.white); 82 jp.setBorder( BorderFactory.createTitledBorder("New Trace Color for " + jlbl.getText()));141 jp.setBorder( BorderFactory.createTitledBorder(jb.getActionCommand()) ); 83 142 jlbl2.setForeground(jcc.getColor()); 84 143 jlbl2.setBackground(Color.white); … … 111 170 }); 112 171 113 jbList.add(jb); 114 115 comp.add(jb); 116 117 return comp; 118 172 lastButton = jb; 173 jbList.addOrReplace(jb); 174 175 return jb; 119 176 } 120 177 -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/Jiggle.java
r3065 r3104 722 722 boolean velocityModelChanged = prefDialog.velocityModelChanged(); // added - aww 2008/03/25 723 723 boolean resetCatCols = prefDialog.catalogColsChanged(); 724 boolean catColorChanged = prefDialog.catalogColorChanged(); 724 725 boolean wfColorChanged = prefDialog.wfColorChanged(); 725 726 boolean mapInSplitChanged = prefDialog.mapInSplitChanged(); … … 873 874 874 875 if (resetCatCols) resetCatPanel(); // -aww 2008/06/10 as test 875 else if (cat Pane != null) catPane.setJiggle(this); // propagates catalog row color property changes876 else if (catColorChanged && catPane != null) catPane.setJiggle(this); // propagates catalog row color property changes 876 877 877 878 savePropertiesDialog(); // runnable in event queue -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/PhaseDialog.java
r1618 r3104 15 15 public class PhaseDialog extends JDialog { 16 16 17 WFPanel wfp; 18 19 Phase ph; 20 MasterView mv; 21 22 /** support old style weight */ 23 int wt; 24 25 String phaseChoice[] = { "P", "S", "Pn", "Sn"}; 26 27 JComboBox phaseCombo; 28 SolutionListComboBox solListCombo; // to select association 29 30 RadioListener radioListener = new RadioListener(); // all buttons will register same instance 31 32 /** 33 * Need Phase, MasterView and WFView to completely handle all the bookkeeping for 34 * changing, adding, deleting phases 35 */ 36 public PhaseDialog(Frame frame, Component comp, WFPanel wfp, MasterView mv, Phase inPh) { 37 38 super (frame, "Phase Description", true); 39 40 //Set our location (0,0) relative to the given component 41 //setLocationRelativeTo(comp); 42 43 this.wfp = wfp; 44 this.ph = inPh; 45 this.mv = mv; 46 47 // Build the dialog box 48 Box box = new Box(BoxLayout.Y_AXIS); 49 50 phaseCombo = makeComboBox(phaseChoice); 51 phaseCombo.setEditable(true); 52 53 JPanel iePanel = createIePanel(); 54 JPanel fmPanel = createFmPanel(); 55 JPanel wtPanel = createWtPanel(); 56 57 JPanel labelPanel = new JPanel(); 58 labelPanel.setLayout(new GridLayout(0, 1)); 59 labelPanel.add(new JLabel("Phase: ", JLabel.RIGHT) ); 60 labelPanel.add(new JLabel("Onset: ", JLabel.RIGHT) ); 61 labelPanel.add(new JLabel("1st Mo: ", JLabel.RIGHT) ); 62 labelPanel.add(new JLabel("Weight: ", JLabel.RIGHT) ); 63 64 JPanel chooserPanel = new JPanel(); 65 chooserPanel.setLayout(new GridLayout(0, 1)); 66 67 chooserPanel.add(phaseCombo); 68 chooserPanel.add(iePanel); 69 chooserPanel.add(fmPanel); 70 chooserPanel.add(wtPanel); 71 72 JPanel descPanel = new JPanel(); 73 descPanel.setLayout(new BoxLayout(descPanel, BoxLayout.X_AXIS)); 74 descPanel.setBorder( new TitledBorder("Phase Description") ); 75 descPanel.add(labelPanel); 76 descPanel.add(chooserPanel); 77 78 solListCombo = new SolutionListComboBox (mv.solList); 79 80 JPanel assocPanel = new JPanel(); 81 assocPanel.setBorder( new TitledBorder("Association") ); 82 assocPanel.add(solListCombo); 83 84 // Set selected Solution in the comboBox to the one in the Masterview's model 85 solListCombo.addActionListener(new SolutionComboHandler() ); 86 87 // set default values to match current phase 88 phaseCombo.setSelectedItem(ph.description.iphase); 89 // useInLocation // aww 06/22/2006 90 JPanel rejectPanel = new JPanel(); // aww 06/22/2006 91 final JCheckBox wtCheckBox = new JCheckBox("Reject from location"); 92 wtCheckBox.setSelected(ph.isReject()); 93 wtCheckBox.addActionListener(new ActionListener() { 94 public void actionPerformed(ActionEvent e) { 95 ph.setReject(wtCheckBox.isSelected()); 17 WFPanel wfp = null; 18 19 Phase ph = null; 20 MasterView mv = null; 21 22 int wt = 0; 23 24 String phaseChoice[] = { "P", "S", "Pn", "Sn", "Pg"}; 25 26 JComboBox phaseCombo = null; 27 SolutionListComboBox solListCombo = null; // to select association 28 29 RadioListener radioListener = new RadioListener(); // all buttons will register same instance 30 31 /** 32 * Need Phase, MasterView and WFView to completely handle all the bookkeeping for changing, adding, deleting phases 33 */ 34 public PhaseDialog(Frame frame, Component comp, WFPanel wfp, MasterView mv, Phase inPh) { 35 36 super(frame, "Phase Description", true); 37 38 //Set our location (0,0) relative to the given component 39 //setLocationRelativeTo(comp); 40 41 this.wfp = wfp; 42 this.ph = inPh; 43 this.mv = mv; 44 45 // the main panel 46 JPanel mainPanel = new JPanel(); // the main dialog panel 47 mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); 48 mainPanel.add(createDescPanel()); 49 mainPanel.add(createAssocPanel()); 50 mainPanel.add(createExpressPanel()); 51 mainPanel.add(createRejectPanel()); // aww 06/22/2006 52 mainPanel.add(createButtonPanel()); 53 54 getContentPane().add(mainPanel); 55 pack(); 56 show(); 57 } 58 59 JComponent createAssocPanel() { 60 JPanel assocPanel = new JPanel(); 61 assocPanel.setBorder( new TitledBorder("Association") ); 62 solListCombo = new SolutionListComboBox(mv.solList); 63 // Set selected Solution in the comboBox to the one in the Masterview's model 64 solListCombo.addActionListener(new SolutionComboHandler()); 65 assocPanel.add(solListCombo); 66 return assocPanel; 67 } 68 69 JComponent createRejectPanel() { 70 Box rejectPanel = Box.createHorizontalBox(); 71 final JCheckBox wtCheckBox = new JCheckBox("Reject from location"); 72 wtCheckBox.setSelected(ph.isReject()); 73 wtCheckBox.addActionListener(new ActionListener() { 74 public void actionPerformed(ActionEvent e) { 75 ph.setReject(wtCheckBox.isSelected()); 76 } 77 }); 78 wtCheckBox.setHorizontalTextPosition(SwingConstants.LEADING); 79 rejectPanel.add(wtCheckBox); 80 return rejectPanel; 81 } 82 83 JComponent createDescPanel() { 84 Box descPanel = Box.createVerticalBox(); 85 descPanel.setBorder( new TitledBorder("Phase Description") ); 86 descPanel.add(createPhPanel()); 87 descPanel.add(createIePanel()); 88 descPanel.add(createFmPanel()); 89 descPanel.add(createWtPanel()); 90 return descPanel; 91 } 92 93 JComponent createButtonPanel() { 94 // define the buttons: [OK] [Delete] [Cancel]? 95 JPanel buttonPanel = new JPanel(); 96 JButton okButton = new JButton("OK"); 97 okButton.addActionListener(new ActionListener() { 98 public void actionPerformed(ActionEvent e) { 99 OKPressed(); 100 } 101 }); 102 buttonPanel.add( okButton ); 103 JButton cancelButton = new JButton("Cancel"); 104 cancelButton.addActionListener(new ActionListener() { 105 public void actionPerformed(ActionEvent e) { 106 CancelPressed(); 107 } 108 }); 109 buttonPanel.add( cancelButton ); 110 return buttonPanel; 111 } 112 113 JComponent createPhPanel() { 114 JPanel panel = new JPanel(new GridLayout(1,2)); // Box.createHorizontalBox(); 115 panel.add(new JLabel("Phase ", JLabel.LEFT)); 116 117 phaseCombo = makeComboBox(phaseChoice); 118 phaseCombo.setEditable(true); 119 phaseCombo.setToolTipText("Only phase type, don't type a 1st motion, qual, or wt here"); 120 phaseCombo.setPreferredSize(new Dimension(50,20)); 121 phaseCombo.setMaximumSize(new Dimension(50,20)); 122 // set default values to match current phase 123 phaseCombo.setSelectedItem(ph.description.iphase); 124 Box box = Box.createHorizontalBox(); 125 box.add(phaseCombo); 126 box.add(Box.createHorizontalGlue()); 127 panel.add(box); 128 return panel; 129 } 130 131 JComponent createIePanel() { 132 JRadioButton button1 = makeButton("i", 'i'); 133 JRadioButton button2 = makeButton("e", 'e'); 134 JRadioButton button3 = makeButton("w", 'w'); 135 136 // Group the radio buttons. 137 ButtonGroup buttonGroup = new ButtonGroup(); 138 buttonGroup.add(button1); 139 buttonGroup.add(button2); 140 buttonGroup.add(button3); 141 142 if (ph.description.ei == "e") button2.setSelected(true); 143 else if (ph.description.ei == "w") button3.setSelected(true); 144 else button1.setSelected(true); // 'i' default 145 146 JPanel panel = new JPanel(new GridLayout(1,2)); 147 panel.add(new JLabel("Onset ", JLabel.LEFT) ); 148 Box box = Box.createHorizontalBox(); 149 box.add(button1); 150 box.add(button2); 151 box.add(button3); 152 panel.add(box); 153 return panel; 154 } 155 156 JComponent createFmPanel() { 157 JRadioButton button1 = makeButton("c", 'c'); 158 JRadioButton button2 = makeButton("d", 'd'); 159 JRadioButton button3 = makeButton("u", 'u'); 160 JRadioButton button4 = makeButton("r", 'r'); 161 JRadioButton button5 = makeButton(".", '.'); 162 163 // Group the radio buttons. 164 ButtonGroup buttonGroup = new ButtonGroup(); 165 buttonGroup.add(button1); 166 buttonGroup.add(button2); 167 buttonGroup.add(button3); 168 buttonGroup.add(button4); 169 buttonGroup.add(button5); 170 171 JPanel panel = new JPanel(new GridLayout(1,2)); 172 panel.add(new JLabel("1st Mo ", JLabel.LEFT) ); 173 174 Box box = Box.createHorizontalBox(); 175 box.add(button1); 176 box.add(button2); 177 box.add(button3); 178 box.add(button4); 179 box.add(button5); 180 panel.add(box); 181 182 button1.setSelected(true); // 'c' default 183 if (ph.description.fm.equals("d.")) button2.setSelected(true); 184 else if (ph.description.fm.equals("u.")) button3.setSelected(true); 185 else if (ph.description.fm.equals("r.")) button4.setSelected(true); 186 else if (ph.description.fm.equals("..")) button5.setSelected(true); 187 188 return panel; 189 190 } 191 192 JComponent createWtPanel() { 193 JRadioButton button0 = makeButton("0", '0'); 194 JRadioButton button1 = makeButton("1", '1'); 195 JRadioButton button2 = makeButton("2", '2'); 196 JRadioButton button3 = makeButton("3", '3'); 197 JRadioButton button4 = makeButton("4", '4'); 198 199 // Group the radio buttons. 200 ButtonGroup buttonGroup = new ButtonGroup(); 201 buttonGroup.add(button0); 202 buttonGroup.add(button1); 203 buttonGroup.add(button2); 204 buttonGroup.add(button3); 205 buttonGroup.add(button4); 206 207 JPanel panel = new JPanel(new GridLayout(1,2)); 208 panel.add(new JLabel("Weight ", JLabel.LEFT) ); 209 210 Box box = Box.createHorizontalBox(); 211 box.add(button0); 212 box.add(button1); 213 box.add(button2); 214 box.add(button3); 215 box.add(button4); 216 panel.add(box); 217 218 // convert 0->1 quality to 0-4 weight 219 int wt = ph.description.getWeight(); 220 switch (wt) { 221 case 0: 222 button0.setSelected(true); // default 223 break; 224 case 1: 225 button1.setSelected(true); 226 break; 227 case 2: 228 button2.setSelected(true); 229 break; 230 case 3: 231 button3.setSelected(true); 232 break; 233 case 4: 234 button4.setSelected(true); 235 break; 236 default: 237 button0.setSelected(true); // default 96 238 } 97 }); 98 rejectPanel.add(wtCheckBox); 99 100 // The express button Panel 101 JPanel expressPanel = createExpressPanel(); 102 103 // define the buttons: [OK] [Delete] [Cancel]? 104 JPanel buttonPanel = new JPanel(); 105 106 JButton okButton = new JButton("OK"); 107 okButton.addActionListener(new ActionListener() { 108 public void actionPerformed(ActionEvent e) { 109 OKPressed(); 110 } 111 }); 112 buttonPanel.add( okButton ); 113 114 JButton cancelButton = new JButton("Cancel"); 115 cancelButton.addActionListener(new ActionListener() { 116 public void actionPerformed(ActionEvent e) { 117 CancelPressed(); 118 } 119 }); 120 buttonPanel.add( cancelButton ); 121 /* Note Delete meaningless here since phase is "new" so won't be in list -aww 122 JButton deleteButton = new JButton("Delete"); 123 deleteButton.addActionListener(new ActionListener() { 124 public void actionPerformed(ActionEvent e) { 125 DeletePressed(); 126 } 127 }); 128 buttonPanel.add( deleteButton ); 129 */ 130 131 // the main panel 132 JPanel mainPanel = new JPanel(); // the main dialog panel 133 mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); 134 135 mainPanel.add(descPanel); 136 mainPanel.add(assocPanel); 137 mainPanel.add(expressPanel); 138 mainPanel.add(rejectPanel); // aww 06/22/2006 139 mainPanel.add(buttonPanel); 140 141 getContentPane().add(mainPanel); 142 143 pack(); 144 show(); 145 } 146 147 /** 148 * create I/E radio button group 149 */ 150 JPanel createIePanel() { 151 JRadioButton button1 = makeButton("i", 'i'); 152 JRadioButton button2 = makeButton("e", 'e'); 153 JRadioButton button3 = makeButton("w", 'w'); 154 155 // Group the radio buttons. 156 ButtonGroup buttonGroup = new ButtonGroup(); 157 buttonGroup.add(button1); 158 buttonGroup.add(button2); 159 buttonGroup.add(button3); 160 161 if (ph.description.ei == "e") button2.setSelected(true); 162 else if (ph.description.ei == "w") button3.setSelected(true); 163 else button1.setSelected(true); // 'i' default 164 165 JPanel panel = new JPanel(); 166 panel.add(button1); 167 panel.add(button2); 168 panel.add(button3); 169 170 return panel; 171 172 } 173 174 /** 175 * create First Motion radio button group 176 */ 177 JPanel createFmPanel() { 178 JRadioButton button1 = makeButton("c", 'c'); 179 JRadioButton button2 = makeButton("d", 'd'); 180 JRadioButton button3 = makeButton("u", 'u'); 181 JRadioButton button4 = makeButton("r", 'r'); 182 JRadioButton button5 = makeButton(".", '.'); 183 184 // Group the radio buttons. 185 ButtonGroup buttonGroup = new ButtonGroup(); 186 buttonGroup.add(button1); 187 buttonGroup.add(button2); 188 buttonGroup.add(button3); 189 buttonGroup.add(button4); 190 buttonGroup.add(button5); 191 192 JPanel panel = new JPanel(); 193 panel.add(button1); 194 panel.add(button2); 195 panel.add(button3); 196 panel.add(button4); 197 panel.add(button5); 198 199 button1.setSelected(true); // 'c' default 200 if (ph.description.fm.equals("d.")) button2.setSelected(true); 201 if (ph.description.fm.equals("u.")) button3.setSelected(true); 202 if (ph.description.fm.equals("r.")) button4.setSelected(true); 203 if (ph.description.fm.equals("..")) button5.setSelected(true); 204 205 return panel; 206 207 } 208 209 /** 210 * create (old style) Weight radio button group 211 */ 212 JPanel createWtPanel() { 213 JRadioButton button0 = makeButton("0", '0'); 214 JRadioButton button1 = makeButton("1", '1'); 215 JRadioButton button2 = makeButton("2", '2'); 216 JRadioButton button3 = makeButton("3", '3'); 217 JRadioButton button4 = makeButton("4", '4'); 218 219 // Group the radio buttons. 220 ButtonGroup buttonGroup = new ButtonGroup(); 221 buttonGroup.add(button0); 222 buttonGroup.add(button1); 223 buttonGroup.add(button2); 224 buttonGroup.add(button3); 225 buttonGroup.add(button4); 226 227 JPanel panel = new JPanel(); 228 panel.add(button0); 229 panel.add(button1); 230 panel.add(button2); 231 panel.add(button3); 232 panel.add(button4); 233 234 // convert 0->1 quality to 0-4 weight 235 int wt = ph.description.getWeight(); 236 if (wt == 0) button0.setSelected(true); // default 237 if (wt == 1) button1.setSelected(true); 238 if (wt == 2) button2.setSelected(true); 239 if (wt == 3) button3.setSelected(true); 240 if (wt == 4) button4.setSelected(true); 241 242 return panel; 243 } 244 245 /** 246 * Make the subPanel that has one-touch express buttons like 'IP0' ... 247 */ 248 JPanel createExpressPanel() { 239 240 return panel; 241 } 242 243 /** 244 * Make the subPanel that has one-touch express buttons like 'IP0' ... 245 */ 246 JComponent createExpressPanel() { 249 247 JPanel pPanel = new JPanel(); 250 248 JPanel sPanel = new JPanel(); … … 253 251 sPanel.setLayout(new BoxLayout(sPanel, BoxLayout.X_AXIS)); 254 252 255 addExpressButton (new JButton("iP0"), pPanel);256 addExpressButton (new JButton("iP1"), pPanel);257 addExpressButton (new JButton("eP2"), pPanel);258 addExpressButton (new JButton("eP3"), pPanel);259 addExpressButton (new JButton("eP4"), pPanel);260 261 addExpressButton (new JButton("iS0"), sPanel);262 addExpressButton (new JButton("iS1"), sPanel);263 addExpressButton (new JButton("eS2"), sPanel);264 addExpressButton (new JButton("eS3"), sPanel);265 addExpressButton (new JButton("eS4"), sPanel);253 addExpressButton(new JButton("iP0"), pPanel); 254 addExpressButton(new JButton("iP1"), pPanel); 255 addExpressButton(new JButton("eP2"), pPanel); 256 addExpressButton(new JButton("eP3"), pPanel); 257 addExpressButton(new JButton("eP4"), pPanel); 258 259 addExpressButton(new JButton("iS0"), sPanel); 260 addExpressButton(new JButton("iS1"), sPanel); 261 addExpressButton(new JButton("eS2"), sPanel); 262 addExpressButton(new JButton("eS3"), sPanel); 263 addExpressButton(new JButton("eS4"), sPanel); 266 264 267 265 JPanel expPanel = new JPanel(); … … 276 274 } 277 275 278 /*----------------------------------------------------------------- 279 * method to stream line adding of buttons 280 */ 281 void addExpressButton (JButton btn, JPanel panel) { 282 btn.addActionListener (new ExpressButtonHandler() ); 283 panel.add(btn); 284 } 285 286 287 // Handle express buttons 276 void addExpressButton(JButton btn, JPanel panel) { 277 btn.addActionListener(new ExpressButtonHandler() ); 278 panel.add(btn); 279 } 280 281 288 282 class ExpressButtonHandler implements ActionListener { 289 283 public void actionPerformed (ActionEvent evt) { … … 296 290 int weight = 4; 297 291 if (wt != null) { 298 weight= Integer.valueOf( wt ).intValue();292 weight = Integer.valueOf( wt ).intValue(); 299 293 } 300 294 String fm = ph.description.fm; … … 317 311 318 312 319 /** 320 * Generic RadioButton maker. Just simplifies the code a bit 321 */ 322 JRadioButton makeButton (String cmd, char mnem) { 323 JRadioButton rb = new JRadioButton(cmd); 324 rb.setMnemonic(mnem); 325 rb.setActionCommand(cmd); 326 rb.addActionListener(radioListener); 327 return rb; 328 } 329 /** 330 * Simplify creation of JComboBoxes 331 */ 313 JRadioButton makeButton(String cmd, char mnem) { 314 JRadioButton rb = new JRadioButton(cmd); 315 rb.setMnemonic(mnem); 316 rb.setActionCommand(cmd); 317 rb.addActionListener(radioListener); 318 return rb; 319 } 320 332 321 public JComboBox makeComboBox(String[] choiceList) { 333 JComboBox cb = new JComboBox(); 334 335 for (int i = 0; i< choiceList.length; i++) 336 { 337 cb.addItem(choiceList[i]); 338 } 339 340 cb.setEditable(true); // allow freeform user input 341 cb.setSelectedItem(phaseChoice[0]); // default selection 342 cb.setMaximumRowCount(4); // items displayed in scrolling window 343 344 cb.setEditable(false); 345 346 Dimension size = cb.getSize(); 347 348 cb.setSize(20, size.height); 349 350 return cb; 351 } 352 353 // BUTTON ACTIONS BELOW 354 /* Action to take when [DELETE] is pressed * Close dialog, delete the selected phase // 355 public void DeletePressed() { 356 // Delete it in Solution's list so listeners know 357 //mv.getSelectedSolution().phaseList.delete(ph); // aww 04/14/2005 358 mv.getSelectedSolution().erase(ph); 322 JComboBox cb = new JComboBox(); 323 324 for (int i = 0; i< choiceList.length; i++) { 325 cb.addItem(choiceList[i]); 326 } 327 328 cb.setEditable(true); // allow freeform user input 329 cb.setSelectedItem(phaseChoice[0]); // default selection 330 cb.setMaximumRowCount(4); // items displayed in scrolling window 331 332 cb.setEditable(false); 333 334 Dimension size = cb.getSize(); 335 336 cb.setSize(20, size.height); 337 338 return cb; 339 } 340 341 public void CancelPressed() { 359 342 this.setVisible(false); 360 343 } 361 */ 362 /** 363 * Action to take when [CANCEL] is pressed. Final disposition is made by the 364 * caller (MultiWFPanel) A new pick will never be added to any phaseList and so 365 * will be truely deleted. An old pick will revert back to its previous values 366 * and time. */ 367 public void CancelPressed() { 368 // TODO 369 this.setVisible(false); 370 } 371 372 /** 373 * Action to take when [OK] is pressed 374 * Close dialog, make changes 375 */ 344 376 345 public void OKPressed() { 377 346 // time is already set by the caller … … 390 359 } 391 360 392 /** 393 * All buttons will register one instance of this listener. The ActionCommand, 394 * 'cmdStr', of the button is used to tell what to do. */ 395 396 class RadioListener implements ActionListener { 397 398 public void actionPerformed(ActionEvent e) { // source is a radio button 361 class RadioListener implements ActionListener { 362 363 public void actionPerformed(ActionEvent e) { // source is a radio button 399 364 400 if (e.getActionCommand().equals("i")) ph.description.ei = "i"; 401 if (e.getActionCommand().equals("e")) ph.description.ei = "e"; 402 if (e.getActionCommand().equals("w")) ph.description.ei = "w"; 403 404 if (e.getActionCommand().equals("c")) ph.description.fm = "c."; 405 if (e.getActionCommand().equals("d")) ph.description.fm = "d."; 406 if (e.getActionCommand().equals("u")) ph.description.fm = "u."; 407 if (e.getActionCommand().equals("r")) ph.description.fm = "r."; 408 if (e.getActionCommand().equals(".")) ph.description.fm = ".."; 409 410 if (e.getActionCommand().equals("0")) wt = 0; 411 if (e.getActionCommand().equals("1")) wt = 1; 412 if (e.getActionCommand().equals("2")) wt = 2; 413 if (e.getActionCommand().equals("3")) wt = 3; 414 if (e.getActionCommand().equals("4")) wt = 4; 415 416 417 // force quality cutoff test here -aww 11/03/05 418 ph.description.setQuality(PhaseDescription.toQuality(wt), true); // convert to "quality" 419 420 } 365 if (e.getActionCommand().equals("i")) ph.description.ei = "i"; 366 else if (e.getActionCommand().equals("e")) ph.description.ei = "e"; 367 else if (e.getActionCommand().equals("w")) ph.description.ei = "w"; 368 369 else if (e.getActionCommand().equals("c")) ph.description.fm = "c."; 370 else if (e.getActionCommand().equals("d")) ph.description.fm = "d."; 371 else if (e.getActionCommand().equals("u")) ph.description.fm = "u."; 372 else if (e.getActionCommand().equals("r")) ph.description.fm = "r."; 373 else if (e.getActionCommand().equals(".")) ph.description.fm = ".."; 374 375 else if (e.getActionCommand().equals("0")) wt = 0; 376 else if (e.getActionCommand().equals("1")) wt = 1; 377 else if (e.getActionCommand().equals("2")) wt = 2; 378 else if (e.getActionCommand().equals("3")) wt = 3; 379 else if (e.getActionCommand().equals("4")) wt = 4; 380 381 // force quality cutoff test here -aww 11/03/05 382 ph.description.setQuality(PhaseDescription.toQuality(wt), true); // convert to "quality" 383 421 384 } 422 423 424 /** Handle changes to the selected Solution that are made in a SolutionCombobox. 425 */ 385 } 386 387 /** Handle changes to the selected Solution that are made in a SolutionCombobox. */ 426 388 class SolutionComboHandler implements ActionListener { 427 389 // this is the action taken when the selectedOrigin is changed … … 432 394 } 433 395 434 } // end of class435 396 } 397 -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/PickingPanel.java
r2533 r3104 181 181 182 182 // Handle button and menu events 183 class DelButtonHandler implements ActionListener {183 class DelButtonHandler extends AbstractAction { // implements ActionListener { 184 184 public void actionPerformed(ActionEvent evt) { 185 185 … … 204 204 } 205 205 206 class RejectButtonHandler implements ActionListener { // aww added 11/09/2006 206 class FlipButtonHandler extends AbstractAction { 207 public void actionPerformed(ActionEvent evt) { 208 double pickTime = mv.masterWFWindowModel.getTimeSpan().getCenter(); 209 MasterView mv = zwfp.wfv.mv; 210 Phase phase = (Phase)zwfp.wfv.phaseList.getNearestToTime(pickTime, mv.getSelectedSolution()); 211 if (phase != null) phase.description.flipPolarity(); 212 int idx = zwfp.wfv.phaseList.indexOf(phase); 213 zwfp.wfv.phaseList.fireListElementStateChanged("PHASE_DESCR", idx, idx); 214 } 215 } 216 217 class RejectButtonHandler extends AbstractAction { // implements ActionListener { // aww added 11/09/2006 207 218 public void actionPerformed(ActionEvent evt) { 208 219 double pickTime = mv.masterWFWindowModel.getTimeSpan().getCenter(); … … 215 226 } 216 227 217 class PickButtonHandler implements ActionListener {228 class PickButtonHandler extends AbstractAction { // implements ActionListener { 218 229 Component c = null; 219 230 … … 293 304 actionMap.put("TOP", new ButtonAction(ButtonAction.TOP)); 294 305 actionMap.put("BOTTOM", new ButtonAction(ButtonAction.BOTTOM)); 306 actionMap.put("DELETE", new DelButtonHandler()); 307 actionMap.put("REJECT", new RejectButtonHandler()); 308 actionMap.put("PICK", new PickButtonHandler(timeLabel)); 309 actionMap.put("FLIP", new FlipButtonHandler()); 295 310 296 311 // add map to zwfp to avoid makePick action when typing 0-4 in timescale combobox -aww … … 318 333 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "TOP"); 319 334 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "BOTTOM"); 335 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_X, 0), "DELETE"); 336 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), "REJECT"); 337 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_P, 0), "PICK"); 338 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_F, 0), "FLIP"); 320 339 321 340 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_BACK_QUOTE, Event.SHIFT_MASK), "iS0"); … … 336 355 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_HOME, Event.SHIFT_MASK), "TOP"); 337 356 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_END, Event.SHIFT_MASK), "BOTTOM"); 357 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK), "DELETE"); 358 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.SHIFT_MASK), "REJECT"); 359 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.SHIFT_MASK), "PICK"); 360 inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.SHIFT_MASK), "FLIP"); 338 361 339 362 … … 341 364 zwfp.setInputMap(JComponent.WHEN_FOCUSED,inputMap); 342 365 zwfp.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,inputMap); 343 366 /* 367 zwfp.addKeyListener(new KeyAdapter() { 368 public void keyPressed(KeyEvent evt) { 369 System.out.println(KeyEvent.VK_NUM_LOCK + " code: " + KeyEvent.getKeyText(evt.getKeyCode()) + 370 " : " + evt.getModifiers() + 371 " : " + KeyEvent.getKeyModifiersText(evt.getModifiers()) 372 ); 373 } 374 }); 375 */ 344 376 } 345 377 -
PP/branches/leap-second-dev-branch/jungle/src/org/trinet/jiggle/PreferencesDialog.java
r3072 r3104 167 167 public void OKPressed() { 168 168 returnValue = JOptionPane.OK_OPTION; 169 catalogDP.setCatalogColumnList ();169 catalogDP.setCatalogColumnListProperty(); 170 170 wfColorsDP.resetComponentColorMap(); 171 171 dispose(); … … 202 202 public boolean resetGUI() { 203 203 return guiLayoutDP.resetGUI || dataSourceChanged(); 204 } 205 206 /** Returns true if any of the catalog color properties were changed. */ 207 public boolean catalogColorChanged() { 208 return catalogDP.colorChanged; 204 209 } 205 210
Note: See TracChangeset
for help on using the changeset viewer.
