Example #1
0
  /**
   * Write a MouseEvent on the link to the server.
   *
   * @param descriptor the MASK that describes the event.
   * @param me the MouseEvent
   * @param latPoint the latitude of the mouse event.
   * @param lonPoint the longitude of the mouse event.
   * @param props an array of strings representing key-value pairs.
   * @param link the link to write the gesture to.
   */
  public static void write(
      int descriptor,
      MouseEvent me,
      float latPoint,
      float lonPoint,
      LinkProperties props,
      Link link)
      throws IOException {

    if (props.getProperty(LPC_GRAPHICID) != null) {
      descriptor = LinkUtil.setMask(descriptor, GRAPHIC_ID_MASK);
    }

    link.start(Link.ACTION_REQUEST_HEADER);
    link.dos.writeFloat(version);
    link.dos.writeInt(descriptor);
    link.dos.writeInt(me.getX());
    link.dos.writeInt(me.getY());
    link.dos.writeInt(me.getClickCount());
    link.dos.writeInt(me.getModifiers());
    link.dos.writeFloat(latPoint);
    link.dos.writeFloat(lonPoint);

    props.write(link);

    link.end(Link.END_TOTAL);
  }
Example #2
0
  /** Write an OMPoint to the Link. */
  public static void write(OMPoint point, Link link, LinkProperties props) throws IOException {

    props.setProperty(LinkPoint.LPC_POINT_OVAL, point.isOval() ? "true" : "false");
    switch (point.getRenderType()) {
      case OMPoint.RENDERTYPE_LATLON:
        LinkPoint.write(
            (float) point.getLat(), (float) point.getLon(), point.getRadius(), props, link.dos);
        break;
      case OMPoint.RENDERTYPE_XY:
        LinkPoint.write(point.getX(), point.getY(), point.getRadius(), props, link.dos);
        break;
      case OMPoint.RENDERTYPE_OFFSET:
        LinkPoint.write(
            (float) point.getLat(),
            (float) point.getLon(),
            point.getX(),
            point.getY(),
            point.getRadius(),
            props,
            link.dos);
        break;
      default:
        Debug.error("LinkPoint.write: point rendertype unknown.");
    }
  }
Example #3
0
  /**
   * An example of how to handle LinkActionRequest.
   *
   * @param lar the LinkActionRequest, so you can get more information about the parameters of the
   *     gesture frome the client.
   * @param link the link to communicate the response back to the client.
   * @throws IOException
   */
  public void handleGesture(LinkActionRequest lar, Link link) throws IOException {

    LinkProperties properties = new LinkProperties();
    properties.setProperty(
        LPC_INFO, ("Mouse Clicked at: x = " + lar.getX() + ", y = " + lar.getY()));

    LinkActionList lal = new LinkActionList(link, properties);
    //        int descriptor = lar.getDescriptor();

    String gid = lar.getProperties().getProperty(LPC_GRAPHICID);
    if (gid == null) {
      System.out.println("Deselecting graphics");
      lal.deselectGraphics();
    } else {
      System.out.println("Selecting graphic");
      lal.modifyGraphic(LinkActionList.MODIFY_SELECT_GRAPHIC_MASK, lar.getProperties());
    }

    lal.end(Link.END_TOTAL);
  }
Example #4
0
  /**
   * Construct an XY point at a screen location..
   *
   * @param px1 x pixel position of the first corner relative to the window origin
   * @param py1 y pixel position of the first corner relative to the window origin
   * @param radius pixel radius of the point.
   * @param properties description of drawing attributes.
   * @param dos DataOutputStream
   * @throws IOException
   */
  public static void write(
      int px1, int py1, int radius, LinkProperties properties, DataOutputStream dos)
      throws IOException {

    dos.write(Link.POINT_HEADER.getBytes());
    dos.writeByte(GRAPHICTYPE_POINT);
    dos.writeByte(RENDERTYPE_XY);
    dos.writeInt(px1);
    dos.writeInt(py1);
    dos.writeInt(radius);
    properties.write(dos);
  }
Example #5
0
  /**
   * Create a lat/lon point.
   *
   * @param lt latitude of north edge, decimal degrees.
   * @param ln longitude of west edge, decimal degrees.
   * @param radius pixel radius of the point.
   * @param properties description of drawing attributes.
   * @param dos DataOutputStream
   * @throws IOException
   */
  public static void write(
      float lt, float ln, int radius, LinkProperties properties, DataOutputStream dos)
      throws IOException {

    dos.write(Link.POINT_HEADER.getBytes());
    dos.writeByte(GRAPHICTYPE_POINT);
    dos.writeByte(RENDERTYPE_LATLON);
    dos.writeFloat(lt);
    dos.writeFloat(ln);
    dos.writeInt(radius);
    properties.write(dos);
  }
Example #6
0
  /**
   * Write a KeyEvent on the link to the server.
   *
   * @param descriptor the MASK that describes the event.
   * @param ke the KeyEvent
   * @param props Properties representing attributes.
   * @param link the Link to write the gesture to.
   */
  public static void write(int descriptor, KeyEvent ke, LinkProperties props, Link link)
      throws IOException {

    link.start(Link.ACTION_REQUEST_HEADER);
    link.dos.writeFloat(version);
    link.dos.writeInt(descriptor);
    link.dos.writeChar(ke.getKeyChar());
    link.dos.writeInt(ke.getModifiers());

    props.write(link);

    link.end(Link.END_TOTAL);
  }
 private void updateLinkProperitesAndCapatilities(Intent intent) {
   mLinkProperties = intent.getParcelableExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY);
   if (mLinkProperties == null) {
     loge("CONNECTED event did not supply link properties.");
     mLinkProperties = new LinkProperties();
   }
   mLinkProperties.setMtu(
       mContext.getResources().getInteger(com.android.internal.R.integer.config_mobile_mtu));
   mLinkCapabilities = intent.getParcelableExtra(PhoneConstants.DATA_LINK_CAPABILITIES_KEY);
   if (mLinkCapabilities == null) {
     loge("CONNECTED event did not supply link capabilities.");
     mLinkCapabilities = new LinkCapabilities();
   }
 }
Example #8
0
  /**
   * Read the DataInputStream, and create an OMPoint. Assumes that the LinkPoint header has been
   * read from the link.
   *
   * @param dis DataInputStream
   * @param propertiesBuffer a LinkProperties object used to cache previous settings that can be set
   *     on the OMPoint being read.
   * @return OMPoint
   * @throws IOException
   * @see com.bbn.openmap.omGraphics.OMPoint
   */
  public static OMPoint read(DataInputStream dis, LinkProperties propertiesBuffer)
      throws IOException {
    OMPoint point = null;
    int x1, y1, radius;
    float lt, ln;

    int renderType = dis.readByte();

    switch (renderType) {
      case RENDERTYPE_LATLON:
        lt = dis.readFloat();
        ln = dis.readFloat();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, radius);
        break;
      case RENDERTYPE_XY:
        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(x1, y1, radius);
        break;
      case RENDERTYPE_OFFSET:
        lt = dis.readFloat();
        ln = dis.readFloat();

        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, x1, y1, radius);
        break;
      default:
    }

    if (point != null) {
      propertiesBuffer = LinkProperties.loadPropertiesIntoOMGraphic(dis, point, propertiesBuffer);

      if (propertiesBuffer != null) {
        point.setOval(
            PropUtils.booleanFromProperties(
                propertiesBuffer, LPC_POINT_OVAL, OMPoint.DEFAULT_ISOVAL));
      }
    }

    return point;
  }
  private void interfaceRemoved(String iface) {
    if (!iface.equals(mIface)) return;

    Log.d(TAG, "Removing " + iface);

    NetworkUtils.stopDhcp(mIface);

    mLinkProperties.clear();
    mNetworkInfo.setIsAvailable(false);
    mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null);

    Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
    msg.sendToTarget();

    msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
    msg.sendToTarget();

    mIface = "";
  }
Example #10
0
  /**
   * Read the link and pull off the gesture, filling in the fields of this object.
   *
   * @param link the link to read from.
   * @return Link.END_TOTAL or Link.END_SECTION
   */
  public String read(Link link) throws IOException {

    float ver = link.dis.readFloat();

    if (ver != version) {
      if (ver == .1) { // Big differece....
        throw new IOException("LinkActionRequest: Versions do not match! DANGER!");
      } else {
        Debug.message("link", "LinkActionRequest: Versions do not match");
      }
    }

    // the second thing we get is the descriptor
    descriptor = link.dis.readInt();
    if (isClientNotification()) {
      // In case it is passed back later to the server - we
      // really don't need to know that it was a notification
      // mask after this, right??
      descriptor = LinkUtil.unsetMask(descriptor, CLIENT_NOTIFICATION_MASK);
      return link.readDelimiter(false);
    } else if (isKeyEvent()) {
      // key event
      key = link.dis.readChar();
      modifiers = link.dis.readInt();
    } else {
      // Mouse event
      x = link.dis.readInt();
      y = link.dis.readInt();
      clickCount = link.dis.readInt();
      modifiers = link.dis.readInt();
      lat = link.dis.readFloat();
      lon = link.dis.readFloat();
    }

    properties = new LinkProperties(link);

    if (LinkUtil.isMask(descriptor, GRAPHIC_ID_MASK)) {
      id = properties.getProperty(LPC_GRAPHICID);
    }

    return link.readDelimiter(false);
  }
 @Override
 public void removeStackedLink(LinkProperties link) {
   mLinkProperties.removeStackedLink(link);
 }
 @Override
 public void addStackedLink(LinkProperties link) {
   mLinkProperties.addStackedLink(link);
 }