public void setLabels() {

    // TODO --- finish set labels

    // tab titles
    tabbedPane.setTitleAt(0, app.getMenu("Properties.Basic"));
    tabbedPane.setTitleAt(1, app.getPlain("xAxis"));
    tabbedPane.setTitleAt(2, app.getPlain("yAxis"));
    tabbedPane.setTitleAt(3, app.getMenu("Grid"));

    // window dimension panel
    dimLabel[0].setText("X " + app.getPlain("min") + ":");
    dimLabel[1].setText("X " + app.getPlain("max") + ":");
    dimLabel[2].setText("Y " + app.getPlain("min") + ":");
    dimLabel[3].setText("Y " + app.getPlain("max") + ":");
    axesRatioLabel.setText(app.getPlain("xAxis") + " : " + app.getPlain("yAxis") + " = ");
    //	dimPanelTitle = "ttt";

    cbView.removeActionListener(this);
    cbView.removeAllItems();
    cbView.addItem(app.getPlain("DrawingPad"));
    cbView.addItem(app.getPlain("DrawingPad2"));
    cbView.removeActionListener(this);

    cbShowMouseCoords.setText(app.getMenu("ShowMouseCoordinates"));
  }
    void updatePanel() {
      cbAxisNumber.removeActionListener(this);
      cbAxisNumber.setSelected(view.getShowAxesNumbers()[axis]);
      cbAxisNumber.addActionListener(this);

      cbManualTicks.removeActionListener(this);
      ncbTickDist.removeItemListener(this);

      cbManualTicks.setSelected(!view.isAutomaticAxesNumberingDistance()[axis]);
      ncbTickDist.setValue(view.getAxesNumberingDistances()[axis]);
      ncbTickDist.setEnabled(cbManualTicks.isSelected());

      cbManualTicks.addActionListener(this);
      ncbTickDist.addItemListener(this);

      cbAxisLabel.removeActionListener(this);
      cbAxisLabel.setSelectedItem(view.getAxesLabels()[axis]);
      cbAxisLabel.addActionListener(this);

      cbUnitLabel.removeActionListener(this);
      cbUnitLabel.setSelectedItem(view.getAxesUnitLabels()[axis]);
      cbUnitLabel.addActionListener(this);

      cbShowAxis.removeActionListener(this);
      cbShowAxis.setSelected(view.getShowXaxis());
      cbShowAxis.addActionListener(this);

      cbTickStyle.removeActionListener(this);
      int type = view.getAxesTickStyles()[axis];
      cbTickStyle.setSelectedIndex(type);
      cbTickStyle.addActionListener(this);

      cbShowAxis.removeActionListener(this);
      cbShowAxis.setSelected(axis == 0 ? view.getShowXaxis() : view.getShowYaxis());
      cbShowAxis.addActionListener(this);

      tfCross.removeActionListener(this);
      if (view.getDrawBorderAxes()[axis]) tfCross.setText("");
      else tfCross.setText("" + view.getAxesCross()[axis]);
      tfCross.setEnabled(!view.getDrawBorderAxes()[axis]);
      tfCross.addActionListener(this);
      tfCross.addFocusListener(this);

      cbPositiveAxis.removeActionListener(this);
      cbPositiveAxis.setSelected(view.getPositiveAxes()[axis]);
      cbPositiveAxis.addActionListener(this);

      cbDrawAtBorder.removeActionListener(this);
      cbDrawAtBorder.setSelected(view.getDrawBorderAxes()[axis]);
      cbDrawAtBorder.addActionListener(this);
    }
Exemplo n.º 3
0
 public void dispose() {
   removeActionListener(l1);
   _box.removeActionListener(l2);
   _var.removePropertyChangeListener(p1);
   _var = null;
   _box = null;
 }
Exemplo n.º 4
0
  void populateStartDate() throws SQLException, Exception {
    startDateS.removeActionListener(this);
    startDateS.removeAllItems();
    dateRange.clear();
    if (sourceTable.sourceListModel.isSelectionEmpty() == false
        && sourceTable.getValueAt(sourceTable.getSelectedRow(), 0).toString() != null) {
      Statement MySQL_Statement = dbConn.createStatement();
      String getMinMaxSQL =
          "SELECT UNIX_TIMESTAMP(DATE_ADD(DATE(MIN(date_time)),INTERVAL 1 DAY)) AS min_date,UNIX_TIMESTAMP(DATE(MAX(date_time))) AS max_date FROM data_sa WHERE site_id = "
              + siteTable.getValueAt(siteTable.getSelectedRow(), 0)
              + " AND source_id = "
              + sourceTable.getValueAt(sourceTable.getSelectedRow(), 0);
      ResultSet minMaxResults = MySQL_Statement.executeQuery(getMinMaxSQL);
      if (minMaxResults.next()) {
        Calendar minCal = Calendar.getInstance();
        minCal.setTimeZone(TimeZone.getTimeZone("GMT+10"));
        minCal.setTimeInMillis(minMaxResults.getLong("min_date") * 1000);
        long maxCal = minMaxResults.getLong("max_date") * 1000;

        while (minCal.getTimeInMillis() <= maxCal) {
          dateRange.add(minCal.getTimeInMillis());
          startDateS.addItem(dateFormatter.format(minCal.getTimeInMillis()));
          minCal.add(Calendar.DATE, 1);
        }
        startDateS.setEnabled(true);
        populateEndDate();
      } else {
        throw new Exception("ERR:NoData");
      }
    } else { // This should never be able to happen
      throw new Exception("NoSource");
    }
    startDateS.addActionListener(this);
  }
Exemplo n.º 5
0
  public void setIndexer(LibrariesIndexer indexer) {
    this.indexer = indexer;

    DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
    DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem();

    categoryChooser.removeActionListener(categoryChooserActionListener);
    typeChooser.removeActionListener(typeChooserActionListener);

    // TODO: Remove setIndexer and make getContribModel 
    // return a FilteredAbstractTableModel
    getContribModel().setIndexer(indexer);

    categoryFilter = null;
    categoryChooser.removeAllItems();

    // Load categories
    categoryChooser.addItem(new DropdownAllItem());
    Collection<String> categories = indexer.getIndex().getCategories();
    for (String category : categories) {
      categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category));
    }

    categoryChooser.setEnabled(categoryChooser.getItemCount() > 1);

    categoryChooser.addActionListener(categoryChooserActionListener);
    if (previouslySelectedCategory != null) {
      categoryChooser.setSelectedItem(previouslySelectedCategory);
    } else {
      categoryChooser.setSelectedIndex(0);
    }

    typeFilter = null;
    typeChooser.removeAllItems();
    typeChooser.addItem(new DropdownAllItem());
    typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex()));
    java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes());
    Collections.sort(types, new LibraryTypeComparator());
    for (String type : types) {
      typeChooser.addItem(new DropdownLibraryOfTypeItem(type));
    }
    typeChooser.setEnabled(typeChooser.getItemCount() > 1);
    typeChooser.addActionListener(typeChooserActionListener);
    if (previouslySelectedType != null) {
      typeChooser.setSelectedItem(previouslySelectedType);
    } else {
      typeChooser.setSelectedIndex(0);
    }

    filterField.setEnabled(contribModel.getRowCount() > 0);

    // Create LibrariesInstaller tied with the provided index
    installer = new LibraryInstaller(indexer, platform) {
      @Override
      public void onProgress(Progress progress) {
        setProgress(progress);
      }
    };
  }
Exemplo n.º 6
0
 public void addActionListener(ActionListener action) {
   if (selector != null) {
     ActionListener[] actions = selector.getActionListeners();
     for (ActionListener a : actions) selector.removeActionListener(a);
     selector.addActionListener(action);
     for (ActionListener a : actions) selector.addActionListener(a);
   }
 }
Exemplo n.º 7
0
 private void populateCombo(Set<SolverFamily> solverFamiliesForState) {
   algorithmCombo.removeAllItems();
   algorithmCombo.removeActionListener(algorithmActionListener);
   for (SolverFamily algo : solverFamiliesForState) {
     algorithmCombo.addItem(algo);
   }
   algorithmCombo.addActionListener(algorithmActionListener);
 }
Exemplo n.º 8
0
  /** update the GUI to reflect the new value */
  protected void setData() {
    // remove us from the action listener list, so we don't get recursive
    _theList.removeActionListener(this);

    // get the current colour
    _theList.setSelectedItem(getNamedColor());

    //
    _theList.addActionListener(this);
  }
 public static void comboSeleccionarSinEvento(JComboBox combo, Object o) {
   ActionListener[] actionListeners = combo.getActionListeners();
   for (ActionListener al : actionListeners) {
     combo.removeActionListener(al);
   }
   combo.setSelectedItem(o);
   for (ActionListener al : actionListeners) {
     combo.addActionListener(al);
   }
 }
Exemplo n.º 10
0
 /** updates the vehicle types combobox */
 public void refreshVehicleTypes() {
   chooseVehicleType_.removeActionListener(
       this); // important: remove all ActionListeners before removing all items
   chooseVehicleType_.removeAllItems();
   VehicleTypeXML xml = new VehicleTypeXML(null);
   for (VehicleType type : xml.getVehicleTypes()) {
     chooseVehicleType_.addItem(type);
   }
   chooseVehicleType_.addActionListener(this);
 }
Exemplo n.º 11
0
  protected void detachFrom(Component jc) {
    listenedTo.remove(jc);
    if (extListener != null && extListener.accept(jc)) {
      extListener.stopListeningTo(jc);
    }
    if (isProbablyAContainer(jc)) {
      detachFromHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      ((JList) jc).removeListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).removeActionListener(this);
    } else if (jc instanceof JTree) {
      ((JTree) jc).getSelectionModel().removeTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).removeActionListener(this);
    } else if (jc instanceof JTextComponent) {
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.removePropertyChangeListener("value", this);
      ((JTextComponent) jc).getDocument().removeDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      ((JColorChooser) jc).getSelectionModel().removeChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).removeChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).removeChangeListener(this);
    } else if (jc instanceof JTable) {
      ((JTable) jc).getSelectionModel().removeListSelectionListener(this);
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.removePropertyChangeListener("name", this);
      Object key = wizardPage.getMapKeyFor(jc);

      if (key != null) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine(
              "Named component removed from hierarchy: "
                  + // NOI18N
                  key
                  + ".  Removing any corresponding "
                  + // NOI18N
                  "value from the wizard settings map."); // NOI18N
        }

        wizardPage.removeFromMap(key);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Stop listening to " + jc); // NOI18N
    }
  }
Exemplo n.º 12
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   EquipmentFacade equipment = (EquipmentFacade) table.getValueAt(row, 0);
   if (comboBox != null) {
     comboBox.removeActionListener(this);
   }
   comboBox = new JComboBox(equipMap.getListFor(equipment).toArray());
   comboBox.setSelectedItem(value);
   comboBox.addActionListener(this);
   return comboBox;
 }
Exemplo n.º 13
0
  /** Parse clicks to cancel the recording if we get a click that's not in the JList (or ESC). */
  protected boolean parseClick(AWTEvent event) {

    if (isFinished()) {
      return false;
    }

    // FIXME add key-based activation/termination?
    boolean consumed = true;
    if (combo == null) {
      combo = getComboBox(event);
      listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
              index = combo.getSelectedIndex();
              if (!combo.isPopupVisible()) {
                combo.removeActionListener(listener);
                setFinished(true);
              }
            }
          };
      combo.addActionListener(listener);
      setStatus("Waiting for selection");
    } else if (event.getID() == KeyEvent.KEY_RELEASED
        && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE
            || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) {
      index = combo.getSelectedIndex();
      setFinished(true);
    }
    // Cancel via click somewhere else
    else if (event.getID() == MouseEvent.MOUSE_PRESSED
        && !AWT.isOnPopup((Component) event.getSource())
        && combo != getComboBox(event)) {
      setFinished(true);
      consumed = false;
    }
    // Cancel via ESC key
    else if (event.getID() == KeyEvent.KEY_RELEASED
        && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ESCAPE) {
      setStatus("Selection canceled");
      setFinished(true);
    } else {
      Log.debug("Event ignored");
    }
    if (list == null && combo.isPopupVisible()) list = tester.findComboList(combo);

    if (isFinished()) {
      combo.removeActionListener(listener);
      listener = null;
    }

    return consumed;
  }
Exemplo n.º 14
0
  // WTF: this does not update packs!!
  // only updating info for selected pack. pulldown menus and info area!
  void updatePacks() {
    for (int i = 0; i < packPanels.size(); i++) {
      if (selectedPack == i && getIndex() >= 0) {
        ModPack pack = ModPack.getPackArray().get(getIndex());
        if (pack != null) {
          String mods = "";
          if (pack.getMods() != null) {
            mods += "<p>This pack contains the following mods by default:</p><ul>";
            for (String name : pack.getMods()) {
              mods += "<li>" + name + "</li>";
            }
            mods += "</ul>";
          }
          packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker());
          packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
          File tempDir =
              new File(
                  OSUtils.getCacheStorageLocation(), "ModPacks" + File.separator + pack.getDir());
          packInfo.setText(
              "<html><img src='file:///"
                  + tempDir.getPath()
                  + File.separator
                  + pack.getImageName()
                  + "' width=400 height=200></img> <br>"
                  + pack.getInfo()
                  + mods);
          packInfo.setCaretPosition(0);

          if (ModPack.getSelectedPack(isFTB()).getServerUrl().equals("")
              || ModPack.getSelectedPack(isFTB()).getServerUrl() == null) {
            server.setEnabled(false);
          } else {
            server.setEnabled(true);
          }
          String tempVer = Settings.getSettings().getPackVer(pack.getDir());
          version.removeActionListener(al);
          version.removeAllItems();
          version.addItem("Recommended");
          if (pack.getOldVersions() != null) {
            for (String s : pack.getOldVersions()) {
              version.addItem(s);
            }
            version.setSelectedItem(tempVer);
          }
          version.addActionListener(al);
        }
      } else {
        packPanels.get(i).setBackground(UIManager.getColor("control"));
        packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
    }
  }
Exemplo n.º 15
0
 void disposeReps() {
   if (_value != null) {
     _value.removeActionListener(this);
   }
   for (int i = 0; i < comboCBs.size(); i++) {
     comboCBs.get(i).dispose();
   }
   for (int i = 0; i < comboVars.size(); i++) {
     comboVars.get(i).dispose();
   }
   for (int i = 0; i < comboRBs.size(); i++) {
     comboRBs.get(i).dispose();
   }
 }
  private void buildAndInstallCodecArray() {
    // remember old value and remove listener
    Object oldValue = cbVideoCodec.getSelectedItem();
    cbVideoCodec.removeActionListener(actionFilter);

    // build up the new cb
    cbVideoCodec.removeAllItems();
    List<String> codecs = new ArrayList<String>(movieList.getVideoCodecsInMovies());
    Collections.sort(codecs);
    for (String codec : codecs) {
      cbVideoCodec.addItem(codec);
    }

    // re-set the value and readd action listener
    if (oldValue != null) {
      cbVideoCodec.setSelectedItem(oldValue);
    }
    cbVideoCodec.addActionListener(actionFilter);

    // remember old value and remove listener
    oldValue = cbAudioCodec.getSelectedItem();
    cbAudioCodec.removeActionListener(actionFilter);

    // build up the new cb
    cbAudioCodec.removeAllItems();
    codecs = new ArrayList<String>(movieList.getAudioCodecsInMovies());
    Collections.sort(codecs);
    for (String codec : codecs) {
      cbAudioCodec.addItem(codec);
    }

    // re-set the value and readd action listener
    if (oldValue != null) {
      cbAudioCodec.setSelectedItem(oldValue);
    }
    cbAudioCodec.addActionListener(actionFilter);
  }
  // This method is called when a cell value is edited by the user.
  @Override
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int rowIndex, int colIndex) {

    DeviceControlTableModel data = (DeviceControlTableModel) table.getModel();
    item_ = data.getPropertyItem(rowIndex);

    // Configure the component with the specified value:
    if (item_.allowed.length == 0) {
      if (item_.hasRange) {
        if (item_.isInteger()) {
          slider_.setLimits((int) item_.lowerLimit, (int) item_.upperLimit);
        } else {
          slider_.setLimits(item_.lowerLimit, item_.upperLimit);
        }
        try {
          slider_.setText((String) value);
        } catch (ParseException ex) {
          Log.log(ex);
        }
        return slider_;
      } else {
        text_.setText((String) value);
        return text_;
      }
    } else {
      ActionListener[] l = combo_.getActionListeners();
      for (int i = 0; i < l.length; i++) {
        combo_.removeActionListener(l[i]);
      }
      combo_.removeAllItems();
      for (int i = 0; i < item_.allowed.length; i++) {
        combo_.addItem(item_.allowed[i]);
      }
      combo_.setSelectedItem(item_.value);

      // end editing on selection change
      combo_.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              fireEditingStopped();
            }
          });

      return combo_;
    }
  }
  @Override
  public void actionPerformed(ActionEvent e) {
    // update dynamic menus
    if (e.getSource() == mSelectorPValueColumn) {
      ((JComboBox) mSelectorPValueRefCategory).removeActionListener(this);
      String pValueColumn = (String) ((JComboBox) mSelectorPValueColumn).getSelectedItem();
      ((JComboBox) mSelectorPValueRefCategory).removeAllItems();
      int column = getTableModel().findColumn(pValueColumn);
      String[] categories = getTableModel().getCategoryList(column);
      for (String category : categories) ((JComboBox) mSelectorPValueRefCategory).addItem(category);
      ((JComboBox) mSelectorPValueRefCategory).addActionListener(this);
    }

    // super does handling of OK, Cancel, view updating, item enabling
    super.actionPerformed(e);
  }
  private void buildAndInstallTagsArray() {
    // remember old value and remove listener
    Object oldValue = cbTag.getSelectedItem();
    cbTag.removeActionListener(actionFilter);

    // build up the new cb
    cbTag.removeAllItems();
    List<String> tags = new ArrayList<String>(movieList.getTagsInMovies());
    Collections.sort(tags);
    for (String tag : tags) {
      cbTag.addItem(tag);
    }

    // re-set the value and readd action listener
    if (oldValue != null) {
      cbTag.setSelectedItem(oldValue);
    }
    cbTag.addActionListener(actionFilter);
  }
  private void buildAndInstallDatasourceArray() {
    // remember old value and remove listener
    Object oldValue = cbDatasource.getSelectedItem();
    cbDatasource.removeActionListener(actionFilter);

    // build up the new cb
    cbDatasource.removeAllItems();
    List<String> datasources =
        new ArrayList<String>(Settings.getInstance().getMovieSettings().getMovieDataSource());
    Collections.sort(datasources);
    for (String datasource : datasources) {
      cbDatasource.addItem(datasource);
    }

    // re-set the value and readd action listener
    if (oldValue != null) {
      cbDatasource.setSelectedItem(oldValue);
    }
    cbDatasource.addActionListener(actionFilter);
  }
  private void buildAndInstallCertificationArray() {
    // remember old value and remove listener
    Object oldValue = cbCertification.getSelectedItem();
    cbCertification.removeActionListener(actionFilter);

    // build up the new cb
    cbCertification.removeAllItems();
    List<Certification> certifications =
        new ArrayList<Certification>(movieList.getCertificationsInMovies());
    Collections.sort(certifications);
    for (Certification cert : certifications) {
      cbCertification.addItem(cert);
    }

    // re-set the value and readd action listener
    if (oldValue != null) {
      cbCertification.setSelectedItem(oldValue);
    }
    cbCertification.addActionListener(actionFilter);
  }
Exemplo n.º 22
0
  public void actionPerformed(ActionEvent e) {

    Object source = e.getSource();

    if (source instanceof JTextField) {
      doTextFieldActionPerformed((JTextField) source);
    } else if (source == cbRegression) {
      cbRegression.removeActionListener(this);
      daModel.setRegressionMode(cbRegression.getSelectedIndex());
      updateRegressionPanel();
      cbRegression.addActionListener(this);
    } else if (source == cbPolyOrder) {
      daModel.setRegressionOrder(cbPolyOrder.getSelectedIndex() + 2);
      statDialog.getController().setRegressionGeo();
      statDialog.getController().updateRegressionPanel();
      setRegressionEquationLabel();

      // force update
      daModel.setRegressionMode(Regression.POLY.ordinal());
    }
  }
Exemplo n.º 23
0
  /**
   * Constructor with a string argument that becomes part of the label of the button.
   *
   * @param settingsPanel : parent window
   */
  public ChooseOntologyPanel(
      SettingsPanel settingsPanel, String bingoDir, String[] choiceArray, String choice_def) {
    super();
    this.bingoDir = bingoDir;
    this.settingsPanel = settingsPanel;
    this.choiceArray = choiceArray;

    // annotationFilePath = new File(bingoDir, "bingo");
    setOpaque(false);
    makeJComponents();
    // Layout with GridLayout.
    setLayout(new GridLayout(1, 0));
    add(choiceBox);

    // defaults

    HashSet<String> choiceSet = new HashSet<String>();
    for (String s : choiceArray) {
      choiceSet.add(s);
    }
    if (choiceSet.contains(choice_def)) {
      choiceBox.setSelectedItem(choice_def);
      this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
      specifiedOntology = (String) choiceBox.getSelectedItem();
      def = true;
    } else {
      choiceBox.removeActionListener(this);
      choiceBox.setEditable(true);
      choiceBox.setSelectedItem(choice_def);
      choiceBox.setEditable(false);
      specifiedOntology = BingoAlgorithm.CUSTOM;
      def = false;
      if (choice_def.endsWith(".obo")) {
        this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(true);
      } else {
        this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
      }
      choiceBox.addActionListener(this);
    }
  }
Exemplo n.º 24
0
  /** Sets the labels according to current locale */
  public void setLabels() {
    regressionLabels = new String[Regression.values().length];
    setRegressionLabels();

    // we need to remove old labels from combobox and we don't want the
    // listener to
    // be operational since it will call unnecessary Construction updates
    int j = cbRegression.getSelectedIndex();
    ActionListener al = cbRegression.getActionListeners()[0];
    cbRegression.removeActionListener(al);
    cbRegression.removeAllItems();

    for (int i = 0; i < regressionLabels.length; i++) {
      cbRegression.addItem(regressionLabels[i]);
    }

    cbRegression.setSelectedIndex(j);
    cbRegression.addActionListener(al);
    ((TitledBorder) regressionPanel.getBorder()).setTitle(app.getMenu("RegressionModel"));
    lblEqn.setText(app.getMenu("Equation") + ":");

    lblEvaluate.setText(app.getMenu("Evaluate") + ": ");
  }
Exemplo n.º 25
0
 @Override
 public void actionPerformed(ActionEvent aE) {
   if (aE.getSource().equals(applianceGroupInput)) {
     applianceTypeInput.removeActionListener(this);
     applianceTypeInput.removeAllItems();
     for (int i = 0;
         i < Appliance.getApplianceTypes(applianceGroupInput.getSelectedIndex()).length;
         i++) {
       applianceTypeInput.addItem(
           Appliance.getApplianceTypes(applianceGroupInput.getSelectedIndex())[i]);
     }
     applianceTypeInput.addActionListener(this);
   } else if (aE.getSource().equals(applianceTypeInput)) {
     // TODO grey out fields that are not required
     // applianceInput21.setEnabled(true);
     // applianceInput22.setEnabled(true);
     // if(applianceInput5.getSelectedItem().toString().equals("Refrigerator")){
     //	applianceInput21.setEnabled(false);
     //	applianceInput22.setEnabled(false);
     // }
   } else if (aE.getSource().equals(sourceTypeInput)) {
     measurementTypeInput.removeAllItems();
     if (sourceTypeInput.getSelectedItem().toString().equals("Appliance")) {
       measurementTypeInput.addItem("AppEnergy");
       measurementTypeInput.addItem("AppPower");
       measurementTypeInput.addItem("ActEnergy");
       measurementTypeInput.addItem("ActPower");
       measurementTypeInput.addItem("Volts");
       measurementTypeInput.addItem("Amps");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Circuit")) {
       measurementTypeInput.addItem("ActPower");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Gas")) {
       measurementTypeInput.addItem("Pulse");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Humidity")) {
       measurementTypeInput.addItem("Humidity");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Light")) {
       measurementTypeInput.addItem("OnTime");
       measurementTypeInput.addItem("LightLevel");
       measurementTypeInput.addItem("AppEnergy");
       measurementTypeInput.addItem("AppPower");
       measurementTypeInput.addItem("ActEnergy");
       measurementTypeInput.addItem("ActPower");
       measurementTypeInput.addItem("Volts");
       measurementTypeInput.addItem("Amps");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Motion")) {
       measurementTypeInput.addItem("Motion");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Temperature")) {
       measurementTypeInput.addItem("Temp");
       measurementTypeInput.addItem("AvgTemp");
     } else if (sourceTypeInput.getSelectedItem().toString().equals("Water")) {
       measurementTypeInput.addItem("Pulse");
     }
   } else if (aE.getSource().equals(roomInput)
       && roomInput.getItemCount() > 0
       && roomInput.getSelectedItem().toString().equals("Add New Room")
       && siteIDInput.getText().toString().split(": ")[0].matches("^\\d{1,10}$")) {
     RoomEditPanel roomEditPanel = new RoomEditPanel(dbConn);
     String[] split = siteIDInput.getText().toString().split(": ");
     roomEditPanel.addRoom(split[0], split[1]);
   }
   // else if (aE.getSource().equals(roomInput) && roomInput.getItemCount()>0 &&
   // !roomInput.getItemAt(0).equals("No Rooms")){
   //	fillGPOs(siteIDInput.getText().split(": ")[0]);
   // }
 }
  public void updateGUI() {

    btBackgroundColor.setForeground(view.getBackground());
    btAxesColor.setForeground(view.getAxesColor());
    btGridColor.setForeground(view.getGridColor());

    cbShowAxes.removeActionListener(this);
    cbShowAxes.setSelected(view.getShowXaxis() && view.getShowYaxis());
    cbShowAxes.addActionListener(this);

    cbShowGrid.removeActionListener(this);
    cbShowGrid.setSelected(view.getShowGrid());
    cbShowGrid.addActionListener(this);

    //      Michael Borcherds 2008-04-11
    cbBoldGrid.removeActionListener(this);
    cbBoldGrid.setSelected(view.getGridIsBold());
    cbBoldGrid.addActionListener(this);

    cbShowMouseCoords.removeActionListener(this);
    cbShowMouseCoords.setSelected(view.getAllowShowMouseCoords());
    cbShowMouseCoords.addActionListener(this);

    cbView.removeActionListener(this);
    if (view == app.getEuclidianView()) cbView.setSelectedIndex(0);
    else cbView.setSelectedIndex(1);
    cbView.addActionListener(this);

    tfMinX.removeActionListener(this);
    tfMaxX.removeActionListener(this);
    tfMinY.removeActionListener(this);
    tfMaxY.removeActionListener(this);
    tfMinX.setText(kernel.format(view.getXmin()));
    tfMaxX.setText(kernel.format(view.getXmax()));
    tfMinY.setText(kernel.format(view.getYmin()));
    tfMaxY.setText(kernel.format(view.getYmax()));
    tfMinX.addActionListener(this);
    tfMaxX.addActionListener(this);
    tfMinY.addActionListener(this);
    tfMaxY.addActionListener(this);

    cbGridType.removeActionListener(this);
    cbGridType.setSelectedIndex(view.getGridType());
    cbGridType.addActionListener(this);

    cbAxesStyle.removeActionListener(this);
    cbAxesStyle.setSelectedIndex(view.getAxesLineStyle());
    cbAxesStyle.addActionListener(this);

    cbGridStyle.removeActionListener(this);
    int type = view.getGridLineStyle();
    for (int i = 0; i < cbGridStyle.getItemCount(); i++) {
      if (type == ((Integer) cbGridStyle.getItemAt(i)).intValue()) {
        cbGridStyle.setSelectedIndex(i);
        break;
      }
    }
    cbGridStyle.addActionListener(this);

    cbGridManualTick.removeActionListener(this);
    boolean autoGrid = view.isAutomaticGridDistance();
    cbGridManualTick.setSelected(!autoGrid);
    cbGridManualTick.addActionListener(this);

    ncbGridTickX.removeItemListener(this);
    ncbGridTickY.removeItemListener(this);
    cbGridTickAngle.removeItemListener(this);
    double[] gridTicks = view.getGridDistances();

    if (view.getGridType() != EuclidianView.GRID_POLAR) {

      ncbGridTickY.setVisible(true);
      gridLabel2.setVisible(true);
      cbGridTickAngle.setVisible(false);
      gridLabel3.setVisible(false);

      ncbGridTickX.setValue(gridTicks[0]);
      ncbGridTickY.setValue(gridTicks[1]);
      gridLabel1.setText("x:");

    } else {
      ncbGridTickY.setVisible(false);
      gridLabel2.setVisible(false);
      cbGridTickAngle.setVisible(true);
      gridLabel3.setVisible(true);

      ncbGridTickX.setValue(gridTicks[0]);
      int val = (int) (view.getGridDistances(2) * 12 / Math.PI) - 1;
      if (val == 5) val = 4; // handle Pi/2 problem
      cbGridTickAngle.setSelectedIndex(val);
      gridLabel1.setText("r:");
    }

    ncbGridTickX.setEnabled(!autoGrid);
    ncbGridTickY.setEnabled(!autoGrid);
    cbGridTickAngle.setEnabled(!autoGrid);
    ncbGridTickX.addItemListener(this);
    ncbGridTickY.addItemListener(this);
    cbGridTickAngle.addItemListener(this);

    tfAxesRatioX.removeActionListener(this);
    tfAxesRatioY.removeActionListener(this);
    double xscale = view.getXscale();
    double yscale = view.getYscale();
    if (xscale >= yscale) {
      tfAxesRatioX.setText("1");
      tfAxesRatioY.setText(nfAxesRatio.format(xscale / yscale));
    } else {
      tfAxesRatioX.setText(nfAxesRatio.format(yscale / xscale));
      tfAxesRatioY.setText("1");
    }
    tfAxesRatioX.addActionListener(this);
    tfAxesRatioY.addActionListener(this);

    xAxisPanel.updatePanel();
    yAxisPanel.updatePanel();
  }
Exemplo n.º 27
0
  /**
   * Sets up the panel with a new set of instances, attempting to guess the correct settings for
   * various columns.
   *
   * @param newInstances the new set of results.
   */
  public void setInstances(Instances newInstances) {

    m_Instances = newInstances;
    m_TTester.setInstances(m_Instances);
    m_FromLab.setText("Got " + m_Instances.numInstances() + " results");

    // Temporarily remove the configuration listener
    m_RunCombo.removeActionListener(m_ConfigureListener);

    // Do other stuff
    m_DatasetKeyModel.removeAllElements();
    m_RunModel.removeAllElements();
    m_ResultKeyModel.removeAllElements();
    m_CompareModel.removeAllElements();
    int datasetCol = -1;
    int runCol = -1;
    String selectedList = "";
    String selectedListDataset = "";
    // =============== BEGIN EDIT melville ===============
    boolean noise = false; // keep track of whether noise levels eval is required
    boolean learning = false; // keep track of whether learning curve eval is required
    boolean fraction =
        false; // keep track of whether fractions of datasets are provided for learning
    // the key on which to base the learning curves (either total instances or fraction)
    int learning_key = -1;
    boolean classificationTask =
        false; // used to determine if regression measures should be selected
    // =============== END EDIT melville ===============
    for (int i = 0; i < m_Instances.numAttributes(); i++) {
      String name = m_Instances.attribute(i).name();
      m_DatasetKeyModel.addElement(name);
      m_RunModel.addElement(name);
      m_ResultKeyModel.addElement(name);
      m_CompareModel.addElement(name);

      // =============== BEGIN EDIT melville ===============
      // If learning curves were generated then treat each
      // dataset + pt combination as a different dataset
      if (name.toLowerCase().equals("key_noise_levels")) {
        // noise overrides learning curves - but treat noise levels
        // like pts on learning curve
        learning_key = i;
        learning = true;
        noise = true;
        // fraction = true;
      } else if (name.toLowerCase().equals("key_fraction_instances") && !noise) {
        // fraction overrides total_instances
        learning_key = i;
        learning = true;
        fraction = true;
      } else if (name.toLowerCase().equals("key_total_instances") && !learning) {
        learning_key = i;
        learning = true;
      } else
      // =============== END EDIT melville ===============
      if (name.toLowerCase().equals("key_dataset")) {
        m_DatasetKeyList.addSelectionInterval(i, i);
        selectedListDataset += "," + (i + 1);
      } else if ((runCol == -1) && (name.toLowerCase().equals("key_run"))) {
        m_RunCombo.setSelectedIndex(i);
        runCol = i;
      } else if (name.toLowerCase().equals("key_scheme")
          || name.toLowerCase().equals("key_scheme_options")
          || name.toLowerCase().equals("key_scheme_version_id")) {
        m_ResultKeyList.addSelectionInterval(i, i);
        selectedList += "," + (i + 1);
        // =============== BEGIN EDIT mbilenko ===============
        // automatic selection of the correct measure for clustering experiments
      } else if (name.toLowerCase().indexOf("pairwise_f_measure") != -1) {
        m_CompareCombo.setSelectedIndex(i);
        m_ErrorCompareCol = i;
      }
      // automatic selection of the correct measure for deduping experiments
      else if (name.toLowerCase().equals("precision")) {
        m_CompareCombo.setSelectedIndex(i);
        // =============== END EDIT mbilenko ===============
      } else if (name.toLowerCase().indexOf("percent_correct") != -1) {
        m_CompareCombo.setSelectedIndex(i);
        classificationTask = true;
      } else if (!classificationTask
          && (name.toLowerCase().indexOf("root_mean_squared_error") != -1)) {
        // automatic selection of the correct measure for regression experiments
        m_CompareCombo.setSelectedIndex(i);
      } else if (name.toLowerCase().indexOf("percent_incorrect") != -1) {
        m_ErrorCompareCol = i;
        // remember index of error for computing error reductions
      }
    }
    // =============== BEGIN EDIT melville ===============
    if (learning) {
      m_DatasetKeyList.addSelectionInterval(learning_key, learning_key);
      selectedListDataset += "," + (learning_key + 1);
      m_CompareModel.addElement("%Error_reduction");
      m_CompareModel.addElement("Top_20%_%Error_reduction");
    }
    // =============== END EDIT melville ===============

    if (runCol == -1) {
      runCol = 0;
    }
    m_DatasetKeyBut.setEnabled(true);
    m_RunCombo.setEnabled(true);
    m_ResultKeyBut.setEnabled(true);
    m_CompareCombo.setEnabled(true);

    // Reconnect the configuration listener
    m_RunCombo.addActionListener(m_ConfigureListener);

    // Set up the TTester with the new data
    m_TTester.setRunColumn(runCol);
    Range generatorRange = new Range();
    if (selectedList.length() != 0) {
      try {
        generatorRange.setRanges(selectedList);
      } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(ex.getMessage());
      }
    }
    m_TTester.setResultsetKeyColumns(generatorRange);

    generatorRange = new Range();
    if (selectedListDataset.length() != 0) {
      try {
        generatorRange.setRanges(selectedListDataset);
      } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(ex.getMessage());
      }
    }
    m_TTester.setDatasetKeyColumns(generatorRange);
    // =============== BEGIN EDIT melville ===============
    m_TTester.setLearningCurve(learning);
    m_TTester.setFraction(fraction);
    if (learning) { // get points on the learning curve
      Attribute attr;
      if (noise) { // override fraction
        attr = m_Instances.attribute("Key_Noise_levels");
      } else if (fraction) {
        attr = m_Instances.attribute("Key_Fraction_instances");
      } else {
        attr = m_Instances.attribute("Key_Total_instances");
      }
      double[] pts = new double[attr.numValues()];
      for (int k = 0; k < attr.numValues(); k++) {
        pts[k] = Double.parseDouble(attr.value(k));
      }
      // sort points
      Arrays.sort(pts);
      m_TTester.setPoints(pts);
    }
    // =============== END EDIT melville ===============
    m_SigTex.setEnabled(true);
    m_PrecTex.setEnabled(true);

    setTTester();
  }
 void clean() {
   combobox.removeActionListener(this);
   combobox = null;
   this.removeAll();
 }