Ejemplo n.º 1
0
  private boolean isUndirectedPanelInputValid() {
    boolean valid = false;
    try {
      Util util = Util.getInstance();
      String s = tfMinDegree.getText();
      if (s == null || s.length() == 0) udmin = 0;
      else udmin = Integer.parseInt(s);
      boolean INCLUSIVE = true;
      if (!util.checkInteger(udmin, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Min Degree is invalid!");

      s = tfMaxDegree.getText();
      if (s == null || s.length() == 0) udmax = Integer.MAX_VALUE;
      else udmax = Integer.parseInt(s);
      if (!util.checkInteger(udmax, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Max Degree is invalid!");
      valid = true;
    } catch (NumberFormatException nfe) {
      JOptionPane.showMessageDialog(
          this,
          "One or more parameters is invalid. Please check values.",
          "Error!",
          JOptionPane.ERROR_MESSAGE);
      valid = false;
    } catch (IllegalArgumentException iae) {
      JOptionPane.showMessageDialog(this, iae.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
      valid = false;
    }
    return valid;
  }
Ejemplo n.º 2
0
  private boolean isDirectedPanelInputValid() {
    boolean valid = false;
    final boolean INCLUSIVE = true;
    try {
      Util util = Util.getInstance();
      String s = tfInDegreeMin.getText();
      if (s != null && s.length() > 0) didmin = Integer.parseInt(s);
      else didmin = 0;
      if (!util.checkInteger(didmin, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Min In-Degree value unacceptable.");

      s = tfInDegreeMax.getText();
      if (s != null && s.length() > 0) didmax = Integer.parseInt(s);
      else didmax = Integer.MAX_VALUE;
      if (!util.checkInteger(didmax, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Max In-Degree value unacceptable.");

      s = tfOutDegreeMin.getText();
      if (s != null && s.length() > 0) dodmin = Integer.parseInt(s);
      else dodmin = 0;
      if (!util.checkInteger(dodmin, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Min Out-Degree value unacceptable.");

      s = tfOutDegreeMax.getText();
      if (s != null && s.length() > 0) dodmax = Integer.parseInt(s);
      else dodmax = Integer.MAX_VALUE;
      if (!util.checkInteger(dodmax, 0, Integer.MAX_VALUE, INCLUSIVE))
        throw new IllegalArgumentException("Min In-Degree value unacceptable.");
      valid = true;
    } catch (NumberFormatException nfe) {
      JOptionPane.showMessageDialog(
          this,
          "One or more arguments is invalid. Please check values.",
          "Error!",
          JOptionPane.ERROR_MESSAGE);
      valid = false;
    } catch (IllegalArgumentException iae) {
      JOptionPane.showMessageDialog(this, iae.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
      valid = false;
    }
    return valid;
  }