예제 #1
0
  /** @param canvas */
  private void drawCornerTextsAndTrack(Canvas canvas) {

    /*
     * Misc text in the information text location on the view like GPS status,
     * Maps status, and point destination/destination bearing, altitude, ...
     * Add shadows for better viewing
     */
    mPaint.setShadowLayer(SHADOW, SHADOW, SHADOW, Color.BLACK);
    mPaint.setColor(Color.WHITE);

    mPaint.setTextAlign(Align.LEFT);
    /*
     * Speed
     */
    canvas.drawText(
        "" + Math.round(mGpsParams.getSpeed()) + "kt", 0, getHeight() / mTextDiv, mPaint);
    /*
     * Altitude
     */
    canvas.drawText(
        "" + Math.round(mGpsParams.getAltitude()) + "ft", 0, getHeight() - mFontHeight, mPaint);

    mPaint.setTextAlign(Align.RIGHT);

    /*
     * Heading
     */
    canvas.drawText(
        "" + Math.round(mGpsParams.getBearing()) + '\u00B0',
        getWidth(),
        getHeight() - mFontHeight,
        mPaint);

    /*
     * Status/destination top right
     */
    if (mErrorStatus != null) {
      mPaint.setColor(Color.RED);
      canvas.drawText(mErrorStatus, getWidth(), getHeight() / mTextDiv * 2, mPaint);
    }

    /*
     * Point above error status
     */
    mPaint.setColor(Color.WHITE);
    if (mPoint != null) {
      canvas.drawText(mPoint, getWidth(), getHeight() / mTextDiv, mPaint);
    } else if (mDestination != null) {
      canvas.drawText(mDestination.toString(), getWidth(), getHeight() / mTextDiv, mPaint);
      if (mDestination.isFound() && mPref.isTrackEnabled() && (!mPref.isSimulationMode())) {
        if (null != mTrackShape) {
          mPaint.setColor(Color.MAGENTA);
          mPaint.setStrokeWidth(4);
          mTrackShape.drawShape(canvas, mOrigin, mScale, mMovement, mPaint, mFace);
        }
      }
    }
  }
  public static void main(String args[]) {
    Connection connection = null;

    try {
      // JNDI lookup of JMS Connection Factory and JMS Destination
      Context context = new InitialContext();
      ConnectionFactory factory = (ConnectionFactory) context.lookup(CONNECTION_FACTORY_NAME);
      Destination destination = (Destination) context.lookup(DESTINATION_NAME);

      connection = factory.createConnection();
      connection.start();

      Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);
      MessageConsumer consumer = session.createConsumer(destination);

      LOG.info(
          "Start consuming messages from "
              + destination.toString()
              + " with "
              + MESSAGE_TIMEOUT_MILLISECONDS
              + "ms timeout");

      // Synchronous message consumer
      int i = 1;
      while (true) {
        Message message = consumer.receive(MESSAGE_TIMEOUT_MILLISECONDS);
        if (message != null) {
          if (message instanceof TextMessage) {
            String text = ((TextMessage) message).getText();
            LOG.info("Got " + (i++) + ". message: " + text);
          }
        } else {
          break;
        }
      }

      consumer.close();
      session.close();
    } catch (Throwable t) {
      LOG.error("Error receiving message", t);
    } finally {
      // Cleanup code
      // In general, you should always close producers, consumers,
      // sessions, and connections in reverse order of creation.
      // For this simple example, a JMS connection.close will
      // clean up all other resources.
      if (connection != null) {
        try {
          connection.close();
        } catch (JMSException e) {
          LOG.error("Error closing connection", e);
        }
      }
    }
  }
예제 #3
0
 /**
  * Construct a Reusable Object to get SSO Uri's <br>
  * note: the password is never transited as we use NTLM Auth
  *
  * @param destination Where in FOL the link should endup
  * @param user The username to authenticate
  * @param pass The password to authenticate
  */
 public GetSSO(Destination destination, String user, String pass) {
   switch (destination) {
     case FOL:
       requestURL = "https://portal.myfanshawe.ca/_layouts/Fanshawe/fol_pass_thru.aspx";
       break;
     case EMAIL:
       requestURL = "https://portal.myfanshawe.ca/_layouts/Fanshawe/fol_pass_thru.aspx?dest=inbox";
       break;
     default:
       throw new IllegalArgumentException(destination.toString() + " is not a valid destination");
   }
   this.user = user;
   this.pass = pass;
 }