示例#1
0
  private ComponentContainer buildTopMenu() {
    HorizontalLayout topMenu = new HorizontalLayout();
    // topMenu.setMargin(true);
    topMenu.setWidth("100%");
    topMenu.addComponent(new Embedded("", new ThemeResource("img/logoSPEOSVBC.gif")));
    VerticalLayout userData = new VerticalLayout();
    userData.addComponent(usernameLl);
    userData.addComponent(clockLl);
    userData.addComponent(foldernameLl);
    topMenu.addComponent(userData);
    topMenu.setComponentAlignment(userData, Alignment.BOTTOM_RIGHT);

    Refresher refresher = new Refresher();
    // refresher.setRefreshInterval(200);
    refresher.addListener(new TopMenuRefresherListener(this, userData));
    topMenu.addComponent(refresher);
    return topMenu;
  }
示例#2
0
  public TrackingScreen() {
    setMargin(true);
    setSpacing(true);
    setSizeFull();

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();

    final SatelliteTable table =
        new SatelliteTable(
            new String[] {"catalogNumber", "commonName"},
            new String[] {"Catalog Number", "Common Name"},
            10);
    table.setSizeUndefined();

    vl.addComponent(table);

    Button compute =
        new Button(
            "Track",
            new Button.ClickListener() {

              private static final long serialVersionUID = -2433152978338766513L;

              public void buttonClick(ClickEvent event) {
                if (table.getValue() == null) {
                  return;
                }

                Item item = table.getItem(table.getValue());
                Long id = (Long) item.getItemProperty("catalogNumber").getValue();
                Satellite sat = satService.getSatellite(id);
                TleEntry entry = satService.getLatestTleEntry(sat);

                vectorLayer.removeAllComponents();
                markerLayer.removeAllComponents();

                try {
                  TLE tle = new TLE(entry.getLine1(), entry.getLine2());

                  AbsoluteDate startDate = new AbsoluteDate(new Date(), TimeScalesFactory.getUTC());

                  double period = sat.getPeriod();
                  double iterations = 2;
                  long step = period > 100 ? 180 : 90;
                  BoundedPropagator boundedProp =
                      SatellitePropagation.getEphemeris(
                          tle, startDate.shiftedBy(-60 * 30), 60L * period * iterations, step);

                  currentTracker = new Tracker(boundedProp);
                  AbsoluteDate date = currentTracker.getStartDate();

                  List<Point> points = new LinkedList<Point>();
                  double lastLon = 0d;

                  while (date.compareTo(currentTracker.getEndDate()) < 0) {
                    GeodeticPoint gp = currentTracker.getPoint(date);

                    double lat = Math.toDegrees(gp.getLatitude());
                    double lon = Math.toDegrees(gp.getLongitude());

                    if (lastLon > 0 && lon < 0) {
                      Vector line = new PolyLine();
                      line.setPoints(points.toArray(new Point[points.size()]));
                      vectorLayer.addVector(line);
                      points.clear();
                    }

                    points.add(new Point(lon, lat));
                    lastLon = lon;
                    date = date.shiftedBy(step);
                  }

                  Vector line = new PolyLine();
                  line.setPoints(points.toArray(new Point[points.size()]));
                  vectorLayer.addVector(line);

                  GeodeticPoint gp = currentTracker.getPoint(startDate);
                  double lat = Math.toDegrees(gp.getLatitude());
                  double lon = Math.toDegrees(gp.getLongitude());

                  marker = new Marker(lon, lat);
                  // URL of marker Icon
                  marker.setIcon("images/satellite_48_hot.png", 24, 24);
                  markerLayer.addMarker(marker);

                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            });
    compute.setWidth("100%");
    compute.addStyleName(Runo.BUTTON_DEFAULT);
    compute.addStyleName(Runo.BUTTON_BIG);

    vl.addComponent(compute);

    addComponent(vl);

    OpenLayersMap map = new OpenLayersMap();
    map.setSizeFull();
    map.setImmediate(true); // update extent and zoom to server as they change

    OpenStreetMapLayer osm = new OpenStreetMapLayer();
    map.addLayer(osm);

    vectorLayer = new VectorLayer();
    vectorLayer.setSelectionMode(SelectionMode.NONE);

    Style defaultStyle = new Style();
    /* Set stroke color to green, otherwise like default style */
    defaultStyle.extendCoreStyle("default");
    defaultStyle.setStrokeColor("#00b963");
    defaultStyle.setStrokeOpacity(0.5);
    defaultStyle.setStrokeWidth(1);

    Style selectStyle = new Style();
    /* Set select color to blue, otherwise like default style */
    selectStyle.extendCoreStyle("default");
    selectStyle.setStrokeColor("#0063b9");
    selectStyle.setStrokeOpacity(0.5);
    selectStyle.setStrokeWidth(1);

    StyleMap styleMap = new StyleMap(defaultStyle, selectStyle, null);
    // make selectStyle inherit attributes not explicitly set
    styleMap.setExtendDefault(true);

    vectorLayer.setStyleMap(styleMap);
    vectorLayer.setDrawindMode(DrawingMode.NONE);

    map.addLayer(vectorLayer);

    // Define a Marker Layer
    markerLayer = new MarkerLayer();

    map.addLayer(markerLayer);

    addComponent(map);
    setExpandRatio(map, 1);

    Refresher r = new Refresher();
    r.setRefreshInterval(1000);
    r.addListener(
        new RefreshListener() {

          private static final long serialVersionUID = 2875834508560395285L;

          @Override
          public void refresh(Refresher source) {
            if (marker != null && currentTracker != null) {
              try {
                AbsoluteDate currentDate = new AbsoluteDate(new Date(), TimeScalesFactory.getUTC());
                GeodeticPoint gp = currentTracker.getPoint(currentDate);
                double lat = Math.toDegrees(gp.getLatitude());
                double lon = Math.toDegrees(gp.getLongitude());

                marker.setLon(lon);
                marker.setLat(lat);
              } catch (OrekitException e) {
                e.printStackTrace();
              }
            }
          }
        });

    addComponent(r);
  }