コード例 #1
0
ファイル: SeaStatePlot.java プロジェクト: kcisek/neptus
  @Override
  public void process(LsfIndex source) {
    LsfIterator<EstimatedState> it = index.getIterator(EstimatedState.class, 200);

    boolean ascending = false;
    EstimatedState lastMin = it.next();

    while (lastMin.getDepth() > 0.5 && it.hasNext() || lastMin.getVx() > 0.2) lastMin = it.next();

    EstimatedState lastMax = lastMin;
    if (lastMin == null || !it.hasNext()) return;
    ascending = it.next().getAlt() >= lastMin.getAlt();

    while (it.hasNext()) {
      EstimatedState state = it.next();
      if (state.getDepth() > 0.5 || state.getVx() > 0.2) continue;
      if (state.getAlt() == -1) continue;
      if (ascending) {
        if (state.getAlt() >= lastMax.getAlt()) lastMax = state;
        else {
          addWave(lastMin, lastMax);
          ascending = false;
          lastMin = lastMax;
        }
      } else {
        if (state.getAlt() <= lastMin.getAlt()) lastMin = state;
        else {
          addWave(lastMax, lastMin);
          ascending = true;
          lastMax = lastMin;
        }
      }
    }
  }
コード例 #2
0
  private void drawPath(
      Graphics2D g, double scaleX, double scaleY, double minX, double minY, double timeStep) {

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setTransform(new AffineTransform());
    g.setColor(new Color(0, 0, 0, 10));

    // IMraLog stateParser = logSource.getLog("EstimatedState");
    // IMCMessage stateEntry;

    LsfIterator<EstimatedState> iterator =
        logSource.getLsfIndex().getIterator(EstimatedState.class);
    if (timeStep > 0)
      iterator =
          logSource.getLsfIndex().getIterator(EstimatedState.class, (long) (timeStep * 1000));

    Point2D lastPt = null;
    EstimatedState state = iterator.next();

    if (state == null) {
      NeptusLog.pub().error("No estimatedstate messages in the log");
      return;
    }
    LocationType ref = IMCUtils.getLocation(state).convertToAbsoluteLatLonDepth();

    LinkedHashMap<Integer, Point2D> lastStates = new LinkedHashMap<>();

    while (state != null) {
      LocationType loc = IMCUtils.getLocation(state).convertToAbsoluteLatLonDepth();
      double[] offsets = loc.getOffsetFrom(ref);

      Point2D pt = new Point2D.Double((offsets[1] - minY) * scaleY, (-minX - offsets[0]) * scaleX);

      if (timeStep == 0) g.setColor(new Color(0, 0, 0, 20));
      else g.setColor(Color.black);

      lastPt = lastStates.get(state.getSrc());

      if (lastPt != null && pt != null) g.draw(new Line2D.Double(lastPt, pt));
      lastStates.put(state.getSrc(), pt);

      state = iterator.next();
    }
  }