/**
  * Constructor.
  *
  * @param value the value to edit.
  * @throws TagFormatException if the tag value cannot be retrieved with the expected type.
  */
 public RationalTagValueComponent(TagValue value) throws TagFormatException {
   super(new FlowLayout(FlowLayout.LEFT, 0, 0));
   m_value = value;
   Rational rational = m_value.getAsRational();
   m_numer = new JTextField("" + rational.numerator, 5);
   m_divider = new JLabel("/");
   m_denom = new JTextField("" + rational.denominator, 5);
   add(m_numer);
   add(m_divider);
   add(m_denom);
 }
 /**
  * Returns the editted value.
  *
  * @return the editted value.
  * @throws TagFormatException if the tag value cannot be retrieved with the expected type.
  */
 public TagValue getTagValue() throws TagFormatException {
   try {
     long numer = Long.parseLong(m_numer.getText());
     long denom = Long.parseLong(m_denom.getText());
     Rational rational = new Rational(numer, denom);
     return new TagValue(m_value.getTag(), rational);
   } catch (NumberFormatException e) {
     e.printStackTrace();
     throw new TagFormatException(
         m_numer.getText() + "/" + m_denom.getText() + " is not a valid rational");
   }
 }
示例#3
0
  /**
   * Construct a GeoKey with a single integer value.
   *
   * @param id GeoKey.Tag number
   * @param v value
   */
  GeoKey(int id, int v) {
    this.id = id;
    this.count = 1;

    this.tag = GeoKey.Tag.get(id);
    this.tagValue = TagValue.get(tag, v);

    if (tagValue == null) {
      this.value = new int[1];
      this.value[0] = v;
    }
  }