/** * 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)); }
/** 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(); } }
/** * 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; }
/** * 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 ""; }
/** 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(); }
// 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); }