Exemplo n.º 1
1
  // Communications
  public void updateStatus(InputStream in) throws IOException {
    DataInputStream din = new DataInputStream(in);
    if (builder.length() != 0) {
      builder.delete(0, builder.length());
    }

    eventTotal.setText(form.format(new Long(din.readLong())));
    dataTotal.setText(Util.convertBytes(builder, din.readLong(), true).toString());
    builder.delete(0, builder.length());
    dataRate.setText(Util.convertBytesRate(builder, din.readDouble(), true).toString());
    eventRate.setText(form.format(new Integer((int) din.readDouble())) + "e/s");
  }
Exemplo n.º 2
0
  // See comment in createericlist regarding HandleViewParams
  private /*synchronized*/ String HandleViewParams(
      String tempString, LinkedList tempList, StringTokenizer st) throws VisualizerLoadException {
    while (tempString.toUpperCase().startsWith("VIEW")) {
      StringTokenizer t = new StringTokenizer(tempString, " \t");
      String s1 = t.nextToken().toUpperCase();
      String s2 = t.nextToken().toUpperCase();
      String s3 = t.nextToken();

      // HERE PROCESS URL's AS YOU DID QUESTIONS

      if (s2.compareTo("ALGO") == 0) {
        add_a_pseudocode_URL(s3);
        // System.out.println("Adding to urls: "+Snaps+":"+s3);
        //                 urlList.append(Snaps+1 +":"+s3);
      } else if (s2.compareTo("DOCS") == 0) {
        add_a_documentation_URL(s3);
        // System.out.println("Adding to urls: "+Snaps+":"+s3);
        //                 if (debug) System.out.println("Adding to urlList: "+Snaps+1+":"+s3);
        //                 urlList.append(Snaps+1 +":"+s3);
      } else if (s2.compareTo("SCALE") == 0) {
        GKS.scale(Format.atof(s3.toUpperCase()), tempList, this);
      } else if (s2.compareTo("WINDOWS") == 0) {
        GKS.windows(Format.atoi(s3.toUpperCase()), tempList, this);
      } else if (s2.compareTo("JUMP") == 0) {
        GKS.jump(Format.atoi(s3.toUpperCase()), tempList, this);
      } else throw (new VisualizerLoadException(s2 + " is invalid VIEW parameter"));
      tempString = st.nextToken();
    }
    //         if (urlList.size() == 0)
    //             urlList.append("**");
    return (tempString);
  }
 /**
  * Called when there was a change in one of the pin values. The event contains the changed value
  * in a string representation and a boolean which is true if the user pressed the 'ok' button and
  * false if the user pressed the 'cancel' button.
  */
 public void pinValueChanged(PinValueEvent e) {
   pinsTable.setEnabled(true);
   if (e.getIsOk()) {
     valuesStr[pinsTable.getSelectedRow()] = e.getValueStr();
     partPins[pinsTable.getSelectedRow()].value =
         Format.translateValueToShort(e.getValueStr(), dataFormat);
   }
   notifyListeners(
       pinsTable.getSelectedRow(), Format.translateValueToShort(e.getValueStr(), dataFormat));
 }
  /**
   * Returns a String representation of the Object <code>value</code>. This invokes <code>format
   * </code> on the current <code>Format</code>.
   *
   * @throws ParseException if there is an error in the conversion
   * @param value Value to convert
   * @return String representation of value
   */
  public String valueToString(Object value) throws ParseException {
    if (value == null) {
      return "";
    }
    Format f = getFormat();

    if (f == null) {
      return value.toString();
    }
    return f.format(value);
  }
    /** Sets the value at a specific row and column. */
    public void setValueAt(Object value, int row, int col) {

      String data = ((String) value).trim();
      try {
        valuesStr[row] = data;
        partPins[row].value = Format.translateValueToShort(data, dataFormat);
        notifyListeners((short) row, partPins[row].value);
      } catch (NumberFormatException nfe) {
        notifyErrorListeners("Illegal value");
        valuesStr[row] = Format.translateValueToString(partPins[row].value, dataFormat);
      }
      repaint();
    }
 /** Sets the pins list's contents with the given vector of PartPinInfo objects. */
 public void setContents(Vector newPins) {
   partPins = new PartPinInfo[newPins.size()];
   valuesStr = new String[newPins.size()];
   newPins.toArray(partPins);
   for (int i = 0; i < partPins.length; i++)
     valuesStr[i] = Format.translateValueToString(partPins[i].value, dataFormat);
   pinsTable.clearSelection();
   pinsTable.revalidate();
   repaint();
 }
 /** Sets the value at a specific row and column. */
 public void setValueAt(Object value, int row, int col) {
   String data = ((String) value).trim();
   if (!getStrAt(row).equals(data)) {
     try {
       short currentValue;
       if (data.equals("") && hideNullValue) currentValue = nullValue;
       else currentValue = Format.translateValueToShort(data, memory.dataFormat);
       notifyListeners((short) row, currentValue);
     } catch (NumberFormatException nfe) {
       notifyErrorListeners("Illegal value");
     }
     repaint();
   }
 }
Exemplo n.º 8
0
  /**
   * Gets the sortable array of the specified column.
   *
   * @param header_value the header value of the column to sort.
   */
  protected SortableArray getSortableArray(String header_value) {
    if (header_value.length() == 0) return null;

    SortableArray array = null;
    if (header_value.equals("R.A.") || header_value.equals("Decl.") || header_value.equals("ID"))
      array = new StringArray(record_list.size());
    else array = new Array(record_list.size());

    for (int i = 0; i < record_list.size(); i++) {
      String value = getCellString(header_value, i);

      if (header_value.equals("R.A.")
          || header_value.equals("Decl.")
          || header_value.equals("ID")) {
        ((StringArray) array).set(i, value);
      } else if (header_value.equals("Max Mag") || header_value.equals("Min Mag")) {
        double mag_value = 0.0;
        if ('0' <= value.charAt(0) && value.charAt(0) <= '9'
            || value.charAt(0) == '-'
            || value.charAt(0) == '+') {
          mag_value = Format.doubleValueOf(value);
        } else {
          mag_value = 100 + Format.doubleValueOf(value.substring(1));
        }
        ((Array) array).set(i, mag_value);
      } else if (header_value.equals("First Date") || header_value.equals("Last Date")) {
        double jd = 0.0;
        if (value.length() > 0) jd = JulianDay.create(value).getJD();
        ((Array) array).set(i, jd);
      } else {
        ((Array) array).set(i, Double.parseDouble(value));
      }
    }

    return array;
  }
Exemplo n.º 9
0
  /**
   * Gets the output string of the cell.
   *
   * @param header_value the header value of the column.
   * @param row the index of row in original order.
   * @return the output string of the cell.
   */
  protected String getCellString(String header_value, int row) {
    Variability record = (Variability) record_list.elementAt(row);

    if (header_value.equals("R.A.")) {
      String coor = record.getStar().getCoor().getOutputString();
      int p = coor.indexOf(' ');
      return coor.substring(0, p);
    }
    if (header_value.equals("Decl.")) {
      String coor = record.getStar().getCoor().getOutputString();
      int p = coor.indexOf(' ');
      return coor.substring(p + 1);
    }
    if (header_value.equals("ID")) {
      if (record.getIdentifiedStar() != null) return record.getIdentifiedStar().getName();
    }
    if (header_value.equals("Max Mag")) {
      return ((XmlMag) record.getBrightestMagnitude().getMag()).getOutputString();
    }
    if (header_value.equals("Min Mag")) {
      return ((XmlMag) record.getFaintestMagnitude().getMag()).getOutputString();
    }
    if (header_value.equals("Mag Range")) {
      return Format.formatDouble(record.getMagnitudeRange(), 5, 2);
    }
    if (header_value.equals("Observations")) {
      return String.valueOf(record.getObservations());
    }
    if (header_value.equals("Positive Observations")) {
      return String.valueOf(record.getPositiveObservations());
    }
    if (header_value.equals("Arc")) {
      return String.valueOf(record.getArcInDays());
    }
    if (header_value.equals("First Date")) {
      String s = record.getFirstDate();
      if (s != null) return s;
    }
    if (header_value.equals("Last Date")) {
      String s = record.getLastDate();
      if (s != null) return s;
    }
    return "";
  }
Exemplo n.º 10
0
  public /*synchronized*/ Color colorSet(String values) {
    String temp;
    int x;
    Color c = Color.black;

    StringTokenizer st = new StringTokenizer(values);
    x = Format.atoi(st.nextToken());
    if (x == 1) c = Color.black;
    else if (x == 2) c = Color.blue;
    else if (x == 6) c = Color.cyan;
    else if (x == 13) c = Color.darkGray;
    else if (x == 11) c = Color.gray;
    else if (x == 3) c = Color.green;
    else if (x == 9) c = Color.lightGray;
    else if (x == 5) c = Color.magenta;
    else if (x == 10) c = Color.orange;
    else if (x == 12) c = Color.pink;
    else if (x == 4) c = Color.red;
    else if (x == 8) c = Color.white;
    else if (x == 7) c = Color.yellow;
    else if (x < 0) c = new Color(-x);
    return c;
  }
 /** Invokes <code>parseObject</code> on <code>f</code>, returning its value. */
 Object stringToValue(String text, Format f) throws ParseException {
   if (f == null) {
     return text;
   }
   return f.parseObject(text);
 }
Exemplo n.º 12
0
  // creates the list of snapshots
  public /*synchronized*/ obj dothis(String inputString) {
    /* Snapshot codes

    29 - rectangle draw
    2 - oval draw
    5 - fill oval
    6 - string
    7 - line & text color
    8 - fill color
    9 - text color (possible to ignore)
    10 - text height
    11 - polydraw
    4 - fill poly
    14 - arc draw
    30 - fill arc
    12 - text style, centered horizontal/vertical
    ???? 45 - url.  Note, when bring up multiple algorithms, the URL's for the most recently
    run algorithm are posted in the upper browser frame
    THE CODE BELOW WOULD INDICATE THIS IS 54, NOT 45 ????

    20 - number of windows.  For static algorithms, 1, 2, 3, 4 have the obvious meaning.
    21 - scale factor
    22 - jump factor

    For 20, 21, 22, the last factor loaded is the one that will affect all snapshots in
    the show

     */

    obj temp = new rectDraw("0 0 0 0", lineC);
    Object urlTest;
    String arrg;

    int graphic_obj_code = Format.atoi(inputString.substring(0, 3));
    StringTokenizer tmp = null;

    switch (graphic_obj_code) {
      case 29:
        temp = new rectDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 2:
        temp = new ovalDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 5:
        temp = new fillOvalDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 6:
        temp =
            new stringDraw(
                inputString.substring(3, (inputString.length())), textC, LineH, LineV, fontMult);
        // 		System.out.println(" printing " + inputString);
        break;
      case 7:
        lineC = colorSet(inputString.substring(3, (inputString.length())));
        textC = lineC;
        break;
      case 8:
        tmp = new StringTokenizer(inputString.substring(2, (inputString.length())));
        fillC = colorSet(tmp.nextToken());
        break;
      case 9:
        textC = colorSet(inputString.substring(3, (inputString.length())));
        break;
      case 10:
        StringTokenizer st = new StringTokenizer(inputString.substring(3, (inputString.length())));
        fontMult = Format.atof(st.nextToken());
        // 		System.out.println("setting fontMult= " + fontMult);
        break;
        // TLN changed on 10/14/97 to accomodate condensed prm files
        // temp=new textHeight(inputString.substring(3,(inputString.length())));
      case 11:
        temp = new polyDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 4:
        temp = new fillPolyDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 64:
        temp = new animated_fillPolyDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 14:
        temp = new arcDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 30:
        temp = new fillArcDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 12:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        LineH = Format.atoi(tmp.nextToken());
        LineV = Format.atoi(tmp.nextToken());
        break;
      case 20:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        // graphWin.setNumViews(Format.atoi(tmp.nextToken()));
        // multiTrigger=true;
        break;
      case 21:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        double tempFloat = Format.atof(tmp.nextToken());
        zoom = tempFloat;
        break;
      case 22:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        //            graphWin.setJump(Format.atoi(tmp.nextToken()));  // This is now a noop in
        // gaigs2
        break;
      case 54:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        //             if (tmp.hasMoreElements()){
        //                 urlTest=tmp.nextToken();
        //                 urlList.append(urlTest);
        //             }
        //             else{
        //                 tmp=new StringTokenizer("**");
        //                 urlTest=tmp.nextToken();
        //                 urlList.append(urlTest);
        //             }
        break;
    } // end switch

    return (temp);
  }
 /** Sets the element at the given index with the given value. */
 public void setValueAt(int index, short value) {
   partPins[index].value = value;
   valuesStr[index] = Format.translateValueToString(value, dataFormat);
   repaint();
 }
Exemplo n.º 14
0
 /**
  * Gets the outer aperture size.
  *
  * @return the outer aperture size.
  */
 public int getOuterApertureSize() {
   return Format.intValueOf(text_outer_aperture.getText());
 }
 // Returns the string at the given location
 private String getStrAt(int index) {
   short currentValue = memory.getValueAsShort((short) (index + startAddress));
   if (currentValue == nullValue && hideNullValue) return "";
   else return Format.translateValueToString(currentValue, dataFormat);
 }
 /** Returns the value at the given index in its string representation. */
 public String getValueAsString(int index) {
   return Format.translateValueToString(
       memory.getValueAsShort((short) (index + startAddress)), dataFormat);
 }