Exemple #1
0
 public Object getTransferData(DataFlavor flavor)
     throws UnsupportedFlavorException, IOException {
   if (!isDataFlavorSupported(flavor)) {
     return null;
   }
   String link = _linkName.getText().trim();
   PositionableLabel l;
   if (link.length() == 0) {
     // return this.deepClone();
     l = new PositionableLabel(getText(), _editor);
   } else {
     l = new LinkingLabel(getText(), _editor, link);
   }
   _decorator.getText(l);
   PositionablePopupUtil util = _decorator.getPositionablePopupUtil();
   l.setPopupUtility(util);
   //            l.setPopupUtility(_decorator.getPositionablePopupUtil().clone(l,
   // l.getTextComponent()));
   if (util.hasBackground()) { // unrotated
     l.setOpaque(true);
   }
   l.setLevel(this.getDisplayLevel());
   return l;
   //           return this.deepClone();
 }
Exemple #2
0
  public void dispose() {
    Distributor.instance().removeMeasurementListener(this);
    active = null;
    error = null;

    super.dispose();
  }
Exemple #3
0
  /** Drive the current state of the display from whether a valid measurement has been received */
  void displayState() {

    if (state) {
      if (isIcon()) {
        super.setIcon(active);
      }
    } else {
      if (isIcon()) {
        super.setIcon(error);
      }
    }

    updateSize();
    revalidate();
    return;
  }
Exemple #4
0
  /** Respond to a measurement by moving to new position */
  public void notify(Measurement m) {
    // only honor measurements to this icon if filtered
    if (filterNumber != null
        && m.getReading() != null
        && !filterNumber.equals(m.getReading().getID())) {
      return;
    }

    // remember this measurement for last position, e.g. for
    // alignment
    lastMeasurement = m;

    // update state based on if valid measurement, fiducial volume
    if (!m.isOkPoint() || m.getZ() < -20 || m.getZ() > 20) {
      state = false;
    } else {
      state = true;
    }

    if (_text) {
      super.setText("" + m.getReading().getID());
    }
    displayState();

    // if the state is bad, leave icon in last position
    if (!state) {
      return;
    }

    // Do a 2D, no-rotation conversion using the saved constants.
    // xn, yn are the RPS coordinates; x, y are the display coordinates.
    double xn = m.getX();
    double yn = m.getY();

    int x = sxOrigin + (int) (sxScale * xn);
    int y = syOrigin + (int) (syScale * yn);

    // and set position
    setLocation(x, y);
  }
 public Positionable finishClone(Positionable p) {
   PositionableLabel pos = (PositionableLabel) p;
   pos._text = _text;
   pos._icon = _icon;
   pos._control = _control;
   //        pos._rotateText = _rotateText;
   pos._unRotatedText = _unRotatedText;
   pos.setLocation(getX(), getY());
   pos._displayLevel = _displayLevel;
   pos._controlling = _controlling;
   pos._hidden = _hidden;
   pos._positionable = _positionable;
   pos._showTooltip = _showTooltip;
   pos.setTooltip(getTooltip());
   pos._editable = _editable;
   if (getPopupUtility() == null) {
     pos.setPopupUtility(null);
   } else {
     pos.setPopupUtility(getPopupUtility().clone(pos, pos.getTextComponent()));
   }
   pos.setOpaque(isOpaque());
   if (_namedIcon != null) {
     pos._namedIcon = cloneIcon(_namedIcon, pos);
     pos.setIcon(pos._namedIcon);
     pos.rotate(_degrees); // this will change text in icon with a new _namedIcon.
   }
   pos.updateSize();
   return pos;
 }