예제 #1
0
  private void drawLegend(Graphics2D g, ColorMap cmap, int var) {
    if (dd.maxVal == null) return;

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setTransform(new AffineTransform());

    g.setColor(new Color(255, 255, 255, 100));
    g.fillRoundRect(10, 10, 100, 170, 10, 10);

    ColorBar cb = new ColorBar(ColorBar.VERTICAL_ORIENTATION, cmap);
    cb.setSize(15, 80);
    g.setColor(Color.black);
    Font prev = g.getFont();
    g.setFont(new Font("Helvetica", Font.BOLD, 14));
    //        g.drawString(varNames[var], 15, 25);
    g.setFont(prev);

    g.translate(15, 45);

    cb.paint(g);

    g.translate(-10, -15);

    try {
      g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(dd.maxVal[var]), 28, 20);
      g.drawString(
          GuiUtils.getNeptusDecimalFormat(2).format((dd.maxVal[var] + dd.minVal[var]) / 2), 28, 60);
      g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(dd.minVal[var]), 28, 100);
    } catch (Exception e) {
      NeptusLog.pub().error(e);
      e.printStackTrace();
    }
    g.translate(10, 120);

    g.drawLine(0, -3, 0, 3);
    g.drawLine(0, 0, 90, 0);
    g.drawLine(90, -3, 90, 3);

    // double meters = scaleX * 90;
    g.drawString(GuiUtils.getNeptusDecimalFormat(2).format(90d / scaleX) + " m", 25, 15);
  }
예제 #2
0
  public static void generateColorMap(
      Point2D[] points,
      Double[] vals,
      Graphics2D destination,
      double width,
      double height,
      int alpha,
      ColorMap colorMap,
      boolean drawPoints) {
    generateInterpolatedColorMap(points, vals, destination, width, height, alpha, colorMap);

    if (points.length == 0) return;

    double minX = points[0].getX();
    double maxX = minX;
    double minY = points[0].getY();
    double maxY = minY;

    for (int i = 0; i < points.length; i++) {
      if (points[i].getX() < minX) minX = points[i].getX();
      else if (points[i].getX() > maxX) maxX = points[i].getX();

      if (points[i].getY() < minY) minY = points[i].getY();
      else if (points[i].getY() > maxY) maxY = points[i].getY();
    }
    if (drawPoints) {
      Graphics2D g = destination;

      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setColor(Color.black);

      double scaleX = (width) / (maxX - minX);
      double scaleY = (height) / (maxY - minY);
      for (int i = 0; i < points.length; i++) {
        double dx = (points[i].getX() - minX) * scaleX;
        double dy = (points[i].getY() - minY) * scaleY;
        g.translate(dx, dy);
        g.drawLine(-3, -3, 3, 3);
        g.drawLine(-3, 3, 3, -3);
        g.drawString("" + GuiUtils.getNeptusDecimalFormat(1).format(vals[i]), 10, 10);
        g.translate(-dx, -dy);
      }
    }
  }
예제 #3
0
  public OperationLimitsPanel(MissionType mt, boolean editArea) {
    this.mt = mt;
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    maxDepthCheck = new JCheckBox(I18n.text("Maximum Depth (m)"));
    minAltitudeCheck = new JCheckBox(I18n.text("Minimum Altitude (m)"));
    maxAltitudeCheck = new JCheckBox(I18n.text("Maximum Altitude (m)"));
    minSpeedCheck = new JCheckBox(I18n.text("Minimum Speed (m/s)"));
    maxSpeedCheck = new JCheckBox(I18n.text("Maximum Speed (m/s)"));
    areaCheck = new JCheckBox(I18n.text("Area Limits"));
    maxVRateCheck = new JCheckBox(I18n.text("Maximum Vertical Rate (m/s)"));

    maxDepthField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxAltitudeField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    minAltitudeField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxSpeedField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    minSpeedField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);
    maxVRateField =
        new JFormattedTextField(GuiUtils.getNeptusDecimalFormat(1) /*NumberFormat.getInstance()*/);

    JPanel tmp = new JPanel(new GridLayout(0, 2, 2, 10));
    tmp.add(maxDepthCheck);
    tmp.add(maxDepthField);

    tmp.add(maxAltitudeCheck);
    tmp.add(maxAltitudeField);

    tmp.add(minAltitudeCheck);
    tmp.add(minAltitudeField);

    tmp.add(maxSpeedCheck);
    tmp.add(maxSpeedField);

    tmp.add(minSpeedCheck);
    tmp.add(minSpeedField);

    tmp.add(maxVRateCheck);
    tmp.add(maxVRateField);

    tmp.add(areaCheck);

    JButton b = new JButton(I18n.text("Select..."));
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            RectangleEditor editor = new RectangleEditor(OperationLimitsPanel.this.mt);
            if (limits.getOpAreaLat() != null) {
              editor.pp =
                  new ParallelepipedElement(
                      MapGroup.getMapGroupInstance(OperationLimitsPanel.this.mt), null);
              editor.pp.setWidth(limits.getOpAreaWidth());
              editor.pp.setLength(limits.getOpAreaLength());
              editor.pp.setYawDeg(Math.toDegrees(limits.getOpRotationRads()));
              LocationType lt = new LocationType();
              lt.setLatitudeDegs(limits.getOpAreaLat());
              lt.setLongitudeDegs(limits.getOpAreaLon());
              editor.pp.setCenterLocation(lt);
              editor.pp.setMyColor(Color.red);
              editor.btnOk.setEnabled(true);
            }
            ParallelepipedElement rectangle = editor.showDialog(OperationLimitsPanel.this);
            if (rectangle != null) {
              double lld[] = rectangle.getCenterLocation().getAbsoluteLatLonDepth();
              limits.setOpAreaLat(lld[0]);
              limits.setOpAreaLon(lld[1]);
              limits.setOpAreaLength(rectangle.getLength());
              limits.setOpAreaWidth(rectangle.getWidth());
              limits.setOpRotationRads(rectangle.getYawRad());
            }
          }
        });
    tmp.add(b);
    if (!editArea) b.setEnabled(false);
    add(tmp);
  }