Пример #1
0
  /**
   * Initializes graphical user interface. Layout of this panel is set to <code>null</code> (no
   * <code>LayoutManager</code>) so that <code>ReceiverView</code> items can be positioned
   * absolutely.
   *
   * @see ReceiverView
   * @see LayoutManager
   */
  private void initializeGui() {

    logger = Utilities.initializeLogger(this.getClass().getName());
    setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
    setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
    setBackground(new Color(GRAY_COLOUR, GRAY_COLOUR, GRAY_COLOUR));
    setLayout(null); // in order to position ReceiverViews absolutely
    refreshPreviewImage();
    // register all receiver views to the ComponentMover
    componentMover = new ComponentMover();
    // add zero coordinate marker views
    addCoordinateZeroMarkerViewsToMap();

    for (Receiver receiver : map.getReceivers()) {

      ReceiverView receiverView = new ReceiverView(receiver, this);
      receiverViews.add(receiverView);
      this.add(receiverView);
      // TODO: location should be calculated with offsets for scaling
      // the image and pixel/meter scaling

      double receiverPositionInMetersX = receiver.getXPos();
      double receiverPositionInMetersY = receiver.getYPos();
      double mapRatioWidth = map.getRatioWidth();
      double mapRatioHeight = map.getRatioHeight();
      int lowerLeftMarkerOffsetXInPixels = map.getLowerLeftMarkerOffsetXInPixels();
      int lowerLeftMarkerOffsetYInPixels = map.getLowerLeftMarkerOffsetYInPixels();

      int receiverPositionInPixelsX =
          calculateReceiverPositionInPixelsX(
              receiverPositionInMetersX, lowerLeftMarkerOffsetXInPixels, mapRatioWidth);
      int receiverPositionInPixelsY =
          calculateReceiverPositionInPixelsY(
              receiverPositionInMetersY, lowerLeftMarkerOffsetYInPixels, mapRatioHeight);

      receiverView.setLocation(receiverPositionInPixelsX, receiverPositionInPixelsY);
      componentMover.registerComponent(receiverView);
    }
  }
Пример #2
0
 /**
  * Instantiates a new <code>HardcodedMapDAO</code> object. Although it is not implemented as a
  * singleton (and therefore multiple instances can be created), only one instance should be used,
  * since multiple instances will read/write from/to the same data source.
  */
 public HardcodedMapDAO() {
   logger = Utilities.initializeLogger(this.getClass().getName());
 }