Esempio n. 1
0
 public String getValueAsString() {
   if (useWholeNumbers) {
     return model.getNumber().toString();
   } else {
     return numberFormat.format(model.getNumber().doubleValue());
   }
 }
Esempio n. 2
0
 private void rbAntiClockwiseActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_rbAntiClockwiseActionPerformed
   if (rbClockwise.isSelected()) {
     angle = 360 / snmSide.getNumber().doubleValue();
   } else {
     angle = -360 / snmSide.getNumber().doubleValue();
   }
   lblAngle.setText(angle + "°");
 } // GEN-LAST:event_rbAntiClockwiseActionPerformed
Esempio n. 3
0
  /**
   * Returns the time since the beginning of the day in milliseconds that this Chooser represents.
   */
  public long getTime() {
    long time = 0;

    time += secondModel.getNumber().longValue() * 1000;
    time += minuteModel.getNumber().longValue() * 60 * 1000;
    time += hourModel.getNumber().longValue() * 60 * 60 * 1000;

    return time;
  }
Esempio n. 4
0
 private void spiSideStateChanged(
     javax.swing.event.ChangeEvent evt) { // GEN-FIRST:event_spiSideStateChanged
   if (rbClockwise.isSelected()) {
     angle = 360 / snmSide.getNumber().doubleValue();
   } else {
     angle = -360 / snmSide.getNumber().doubleValue();
   }
   lblAngle.setText(angle + "°");
 } // GEN-LAST:event_spiSideStateChanged
Esempio n. 5
0
        public void actionPerformed(ActionEvent evt) {

          // clear selection
          list.getListComponent().clearSelection();

          int from = fromSpinnerModel.getNumber().intValue();
          int to = toSpinnerModel.getNumber().intValue();

          try {
            ExpressionFormat format = new ExpressionFormat(textField.getText());

            // pad episode numbers with zeros (e.g. %02d) so all numbers have the same number of
            // digits
            NumberFormat numberFormat = NumberFormat.getIntegerInstance();
            numberFormat.setMinimumIntegerDigits(max(2, Integer.toString(max(from, to)).length()));
            numberFormat.setGroupingUsed(false);

            List<String> names = new ArrayList<String>();

            int min = min(from, to);
            int max = max(from, to);

            for (int i = min; i <= max; i++) {
              Bindings bindings = new SimpleBindings();

              // strings
              bindings.put("i", numberFormat.format(i));

              // numbers
              bindings.put("index", i);
              bindings.put("from", from);
              bindings.put("to", to);

              names.add(format.format(bindings, new StringBuffer()).toString());
            }

            if (signum(to - from) < 0) {
              Collections.reverse(names);
            }

            // try to match title from the first five names
            Collection<String> title =
                new SeriesNameMatcher()
                    .matchAll(
                        (names.size() < 5 ? names : names.subList(0, 4)).toArray(new String[0]));

            list.setTitle(title.isEmpty() ? "List" : title.iterator().next());

            list.getModel().clear();
            list.getModel().addAll(names);
          } catch (Exception e) {
            UILogger.log(Level.WARNING, ExceptionUtilities.getMessage(e), e);
          }
        }
Esempio n. 6
0
 @Override
 public void stateChanged(ChangeEvent e) {
   // a quick way of setting end of day, just set hours to 24
   if (hourModel.getNumber().longValue() == 24) {
     hourModel.setValue(23);
     minuteModel.setValue(59);
     secondModel.setValue(59);
   }
 }
Esempio n. 7
0
  /**
   * Constructs and returns a worker thread which can perform a match as specified by the current
   * state of this component.
   *
   * @return new worker thread
   * @throws RuntimeException if the current state does not fully specify a multi query job; such
   *     exceptions will have comprehensible messages
   */
  private MatchWorker createMatchWorker() {

    /* Acquire state from this panel's GUI components. */
    String sUrl = urlField_.getText();
    if (sUrl == null || sUrl.trim().length() == 0) {
      throw new IllegalArgumentException("No " + service_.getName() + " URL given");
    }
    URL serviceUrl;
    try {
      serviceUrl = new URL(sUrl);
    } catch (MalformedURLException e) {
      throw (IllegalArgumentException)
          new IllegalArgumentException("Bad " + service_.getName() + " URL syntax: " + sUrl)
              .initCause(e);
    }
    ConeErrorPolicy erract = (ConeErrorPolicy) erractSelector_.getSelectedItem();
    TopcatModel tcModel = tcModel_;
    if (tcModel == null) {
      throw new NullPointerException("No table selected");
    }
    final StarTable inTable = tcModel.getApparentStarTable();
    int[] rowMap = tcModel.getViewModel().getRowMap();
    ColumnData raData = raSelector_.getColumnData();
    ColumnData decData = decSelector_.getColumnData();
    ColumnData srData = srSelector_.getColumnData();
    if (raData == null) {
      throw new NullPointerException("No RA column given");
    }
    if (decData == null) {
      throw new NullPointerException("No Dec column given");
    }
    Number parNum = parallelModel_.getNumber();
    int parallelism = parNum == null ? 1 : parNum.intValue();
    MulticoneMode mcMode = (MulticoneMode) modeSelector_.getSelectedItem();
    StarTableFactory tfact = ControlWindow.getInstance().getTableFactory();

    /* Assemble objects based on this information. */
    ConeSearcher searcher = service_.createSearcher(serviceUrl, tfact);
    Coverage coverage = coverageModel_.isSelected() ? service_.getCoverage(serviceUrl) : null;
    DatasQuerySequenceFactory qsf = new DatasQuerySequenceFactory(raData, decData, srData, rowMap);
    ConeMatcher matcher =
        mcMode.createConeMatcher(searcher, erract, inTable, qsf, coverage, parallelism);
    ResultHandler resultHandler =
        mcMode.createResultHandler(this, tfact.getStoragePolicy(), tcModel, inTable);

    /* Create MatchWorker encapsulating all of this. */
    MatchWorker worker = new MatchWorker(matcher, resultHandler, tcModel, inTable);

    /* Perform post-construction configuration of constituent objects
     * as required. */
    qsf.setMatchWorker(worker);
    resultHandler.setMatchWorker(worker);

    /* Return worker thread. */
    return worker;
  }
Esempio n. 8
0
 private void jButton1ActionPerformed(ActionEvent evt) { // event OK!
   if (hexboard != null) hexboard.setVisible(false);
   SpinnerNumberModel model = (SpinnerNumberModel) jSpinner1.getModel();
   int size = model.getNumber().intValue();
   initHexboard(size);
   jFrame1.setVisible(false);
   String strategy1 = (String) jComboBox1.getSelectedItem();
   String strategy2 = (String) jComboBox2.getSelectedItem();
   controller.startNewGameAction(size, strategy1, strategy2);
 } //
  public Apartamento nuevoApartamento() {
    Torre torre = (Torre) mdlTorre.getSelectedItem();
    int piso = mdlPiso.getNumber().intValue();
    String telefono = txtTelefono.getText();
    String citofono = txtCitofono.getText();
    String placa = txtPlaca.getText();

    Apartamento a = new Apartamento(torre, placa, piso, citofono, telefono);
    return a;
  }
  @Override
  public void stateChanged(final ChangeEvent e) {
    logger.entering(BudgetOverviewPanel.class.getName(), "stateChanged");

    if (e.getSource() == yearSpinner) {
      int year = (Integer) model.getNumber();

      budgetPanel.setBudgetYear(year);
    }

    logger.exiting(BudgetOverviewPanel.class.getName(), "stateChanged");
  }
    public Object getPropertyValue() {
      GregorianCalendar result = new GregorianCalendar();

      result.setTimeZone(timezone);

      result.set(Calendar.YEAR, year.getNumber().intValue());
      int mi = 0;
      String ms = month.getValue().toString();
      for (int i = 0; i < MONTH_STRINGS.length; i++) {
        if (MONTH_STRINGS[i].equals(ms)) {
          mi = i;
          break;
        }
      }
      result.set(Calendar.MONTH, mi);
      result.set(Calendar.DATE, day.getNumber().intValue());
      result.set(Calendar.HOUR_OF_DAY, hour.getNumber().intValue());
      result.set(Calendar.MINUTE, min.getNumber().intValue());
      result.set(Calendar.SECOND, sec.getNumber().intValue());

      return result;
    }
Esempio n. 12
0
  /** update instruction if GUI changes */
  void guiChanged() {
    Play instruction = (Play) PlayEditor.this.inst;

    instruction.setHandle(handleModel.getNumber().intValue());

    instruction.setBrk((String) loop.getSelectedItem());

    int flag = 0;
    if (wavbrk1.isSelected()) {
      flag |= 0x01;
    }
    if (wavbrk2.isSelected()) {
      flag |= 0x02;
    }
    instruction.setWaveBrkFlags(flag);

    // tell the world
    updated();
  }
  private void spnTonnageStateChanged(
      javax.swing.event.ChangeEvent evt) { // GEN-FIRST:event_spnTonnageStateChanged
    javax.swing.SpinnerNumberModel n = (SpinnerNumberModel) spnTonnage.getModel();
    javax.swing.JComponent editor = spnTonnage.getEditor();
    javax.swing.JFormattedTextField tf =
        ((javax.swing.JSpinner.DefaultEditor) editor).getTextField();

    // get the value from the text box, if it's valid.
    try {
      spnTonnage.commitEdit();
    } catch (java.text.ParseException pe) {
      // Edited value is invalid, spinner.getValue() will return
      // the last valid value, you could revert the spinner to show that:
      if (editor instanceof javax.swing.JSpinner.DefaultEditor) {
        tf.setValue(spnTonnage.getValue());
      }
      return;
    }

    CurAmmo = n.getNumber().intValue();
  } // GEN-LAST:event_spnTonnageStateChanged
Esempio n. 14
0
 public int getSide() {
   return snmSide.getNumber().intValue();
 }
 public void actionPerformed(ActionEvent evt) {
   pc = (String) modelA.getValue();
   turns = spin.getNumber().intValue();
 }
Esempio n. 16
0
 @Override
 public void assignValues() {
   dateAndTime.setDay(new Day(dayModel.getNumber().intValue()));
 }
Esempio n. 17
0
 @Override
 public Component getMissingComponent() {
   return new Day(dayModel.getNumber().intValue());
 }
Esempio n. 18
0
 /** Match the Y AstAxisLabels gap to that shown. */
 protected void matchYGap() {
   astAxisLabels.setYGap(ySpinnerModel.getNumber().doubleValue());
 }
Esempio n. 19
0
  private void analyzeFile(File file) {
    InputStream f = null;
    try {
      // Init the main set
      charOccurrences = new TreeSet<CharLongPair>(new CharLongPairComparator());
      f = new BufferedInputStream(new FileInputStream(file));
      long totalLength = f.available();
      /// Count the characters
      char c;
      for (int i = 0; i < totalLength; i++) {
        c = (char) f.read();
        if (c == -1) {
          break;
        }
        Iterator<CharLongPair> it = charOccurrences.iterator();
        while (it.hasNext()) {
          CharLongPair cp = new CharLongPair(it.next());
          if (cp.getC() == c) {
            charOccurrences.remove(cp);
            cp.setL(cp.getL() + 1);
            charOccurrences.add(cp);
          }
          continue; // Don't create a new dataset
        }
        charOccurrences.add(new CharLongPair(c, 1));
      }
      /// Fill the table with the counts
      // Get the number of rows to display
      SpinnerNumberModel displayModel = (SpinnerNumberModel) displaySpinner.getModel();
      int displayRows = displayModel.getNumber().intValue();
      Iterator<CharLongPair> it = charOccurrences.iterator();

      Vector tableData = new Vector();
      for (; displayRows > 0; displayRows--) {
        if (!it.hasNext()) {
          break;
        }
        CharLongPair cp = it.next();
        Vector rowData = new Vector();
        rowData.add(cp.getC());
        rowData.add(cp.getL());
        rowData.add(100 * (cp.getL() / totalLength));
        tableData.add(rowData);
      }
      Vector colNames = new Vector();
      colNames.add("Character");
      colNames.add("Count");
      colNames.add("Percentage");
      charPercentageTable.setModel(new DefaultTableModel(tableData, colNames));
    } catch (FileNotFoundException ex) {
      Logger.getLogger(StatisticalAnalysisFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
      Logger.getLogger(StatisticalAnalysisFrame.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      try {
        f.close();
      } catch (IOException ex) {
        Logger.getLogger(StatisticalAnalysisFrame.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  }
Esempio n. 20
0
  public void actionPerformed(ActionEvent e) {
    SpinnerNumberModel m = ((SpinnerNumberModel) daysnr.getModel());
    int days = m.getNumber().intValue();
    String location = ((JTextField) loc).getText();
    java.util.List<PointOfInterest> points = parent.textFieldPoints(location);
    if (!points.isEmpty()) {
      double latitude = points.get(0).getLatlon().latitude.getDegrees(),
          longitude = points.get(0).getLatlon().longitude.getDegrees();
      // we want only the firs two decimals
      latitude = ((double) ((long) (latitude * 100))) / 100;
      longitude = ((double) ((long) (latitude * 100))) / 100;
      String APIKey = "65ea00ff33143650113112";
      String address =
          "http://free.worldweatheronline.com/feed/weather.ashx?"
              + "key="
              + APIKey
              + "&num_of_days="
              + days
              + "&q="
              + latitude
              + ","
              + longitude
              + "&format=json&cc=no";
      try {
        URL link = new URL(address);
        URLConnection yc = link.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
        Vector<WeatherElements> elem = new Vector<WeatherElements>();
        String jsonFile = in.readLine();
        int i1 = 0, i2 = 0;
        for (int i = 0; i < days; i++) {
          i1 = jsonFile.indexOf("\"date\"", i2) + 9;
          i2 = jsonFile.indexOf("\"", i1);
          String date = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"precipMM\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String rain = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"tempMaxC\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String tempMax = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"tempMinC\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String tempMin = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"value\"", i2) + 10;
          i2 = jsonFile.indexOf("\"", i1);
          String weatherStatus = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"value\"", i2) + 10;
          i2 = jsonFile.indexOf("\"", i1);
          String imgLink = jsonFile.substring(i1, i2);
          imgLink = imgLink.replace("\\", "");
          i2++;

          i1 = jsonFile.indexOf("\"winddirDegree\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windDirDegree = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"winddirection\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windDir = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"windspeedKmph\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windSpeed = jsonFile.substring(i1, i2);
          i2++;

          WeatherElements o =
              new WeatherElements(
                  date,
                  rain,
                  tempMax,
                  tempMin,
                  weatherStatus,
                  imgLink,
                  windDirDegree,
                  windDir,
                  windSpeed);
          elem.add(o);
        }

        weatherIcon.setVisible(true);
        dateout.setText(elem.elementAt(0).date);
        weatherIcon.setText("<html><img src=\"" + elem.elementAt(0).imgLink + "\" /></html>");
        weatherstatus.setText("<html><h1>" + elem.elementAt(0).weatherStatus + "</h1></html>");
        temperature.setText(
            "<html>Temperatures:<br />Temp min: "
                + elem.elementAt(0).tempMin
                + "°C<br />Temp max: "
                + elem.elementAt(0).tempMax
                + "°C</html>");
        rain.setText("Rain: " + elem.elementAt(0).rain + " mm");
        wind.setText(
            "<html>Wind: <br />"
                + "<img src=\"http://www.worldweatheronline.com"
                + "/App_Themes/Default/images/wind/"
                + elem.elementAt(0).windDir
                + ".png\" /><br />"
                + "Wind speed: "
                + elem.elementAt(0).windSpeed
                + "Km/h<br />"
                + elem.elementAt(0).windDir
                + "("
                + elem.elementAt(0).windDirDegree
                + "°)</html>");

        buttons.removeAll();
        pageNum.removeAll();
        buttons.updateUI();
        pageNum.updateUI();

        JButton previous = new JButton("Previous");
        previous.setEnabled(false);
        previous.setName("prev");

        JButton next = new JButton("Next");
        next.setName("next");

        if (days == 1) {
          next.setEnabled(false);
        }

        JTextField current = new JTextField("1", 3);
        current.setEditable(false);
        JTextField maxNum = new JTextField("" + elem.size(), 3);
        maxNum.setEditable(false);
        pageNum.add(current);
        pageNum.add(maxNum);

        previous.addActionListener(
            new WeatherButtonsActionListener(
                previous,
                next,
                weatherIcon,
                dateout,
                weatherstatus,
                temperature,
                rain,
                wind,
                elem,
                current));
        next.addActionListener(
            new WeatherButtonsActionListener(
                previous,
                next,
                weatherIcon,
                dateout,
                weatherstatus,
                temperature,
                rain,
                wind,
                elem,
                current));
        buttons.add(next);
        buttons.add(previous);
        JButton genHTML = new JButton("Generate HTML");
        genHTML.addActionListener(new genHTMLWeatherReport(parent, elem));
        buttons.add(genHTML);
      } catch (Exception ex) {
        parent.standardDialogBox("Fetching data error", "Somethnig goes wrong with the connection");
      }
    } else {
      parent.standardDialogBox("Incorrect input", "Input is incorrect!");
    }
  }