Exemple #1
0
  public void addTriggerToParking(TaxiwayParkingModel model) {
    Rectangle2D square = ((java.awt.geom.Ellipse2D.Float) model.getParkingCircle()).getBounds2D();
    square.setFrame(
        square.getX() - (double) (20F * scale),
        square.getY() - (double) (20F * scale),
        square.getWidth() + (double) (40F * scale),
        square.getHeight() + (double) (40F * scale));
    TriggerModel triggerModel = new TriggerModel();
    triggerModel.setShouldNotify(false);
    triggerModel.setType73("YES");
    triggerModel.setTypeJet("YES");
    triggerModel.setShouldNotify(true);
    java.awt.geom.Point2D.Float point =
        new java.awt.geom.Point2D.Float(
            (float) (square.getX() + square.getWidth() / 2D),
            (float) (square.getY() + square.getHeight() / 2D));
    java.awt.geom.Point2D.Float vertexPoints[] = new java.awt.geom.Point2D.Float[4];
    vertexPoints[0] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float((float) square.getX(), (float) square.getY()),
            model.getHeading());
    vertexPoints[1] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) square.getX(), (float) (square.getY() + square.getHeight())),
            model.getHeading());
    vertexPoints[2] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) (square.getX() + square.getWidth()),
                (float) (square.getY() + square.getHeight())),
            model.getHeading());
    vertexPoints[3] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) (square.getX() + square.getWidth()), (float) square.getY()),
            model.getHeading());
    for (int i = 0; i < 4; i++) {
      VertexModel vertexModel = new VertexModel();
      vertexModel.setShouldNotify(false);
      vertexModel.setLatLon(
          Utilities.getLatLonForPixel(
              model.getCenterPoint().getLat(),
              model.getCenterPoint().getLon(),
              vertexPoints[i].getX(),
              vertexPoints[i].getY(),
              scale));
      vertexModel.setShouldNotify(true);
      triggerModel.addVertexModel(vertexModel);
    }

    addTriggerModel(triggerModel);
  }
Exemple #2
0
 public void addStationToParking(TaxiwayParkingModel model) {
   Rectangle2D square = ((java.awt.geom.Ellipse2D.Float) model.getParkingCircle()).getBounds2D();
   SceneryModel sceneryModel = new SceneryModel();
   sceneryModel.setShouldNotify(false);
   sceneryModel.setName("{0da416ee-c523-4d81-a562-9ce503f28468}");
   sceneryModel.setHeading(model.getHeading());
   java.awt.geom.Point2D.Float point =
       new java.awt.geom.Point2D.Float(
           (float) (square.getX() + square.getWidth() / 2D),
           (float) (square.getY() + square.getHeight() / 2D));
   java.awt.geom.Point2D.Float sceneryPoint =
       Utilities.rotatePoint(
           point,
           new java.awt.geom.Point2D.Float(
               (float) (square.getX() + square.getWidth() / 2D),
               (float) (square.getY() - 27.5D * (double) scale)),
           model.getHeading());
   sceneryModel.setLatLon(
       Utilities.getLatLonForPixel(
           model.getCenterPoint().getLat(),
           model.getCenterPoint().getLon(),
           sceneryPoint.getX(),
           sceneryPoint.getY(),
           scale));
   sceneryModel.setShouldNotify(true);
   addSceneryModel(sceneryModel);
 }
  protected Angle computeIconRadius(DrawContext dc, double regionPixelSize, Sector drawSector) {
    double minCosLat =
        Math.min(drawSector.getMinLatitude().cos(), drawSector.getMaxLatitude().cos());
    if (minCosLat < 0.001) return Angle.POS180;

    Rectangle2D iconDimension = this.computeDrawDimension(regionPixelSize); // Meter
    double dLat = iconDimension.getHeight() / dc.getGlobe().getRadius();
    double dLon = iconDimension.getWidth() / dc.getGlobe().getRadius() / minCosLat;
    return Angle.fromRadians(Math.sqrt(dLat * dLat + dLon * dLon) / 2);
  }
  protected List<Sector> computeSectors(DrawContext dc) {
    if (this.locations == null || !this.locations.iterator().hasNext()) return null;

    // Compute all locations bounding sector, then add some padding for the icon half diagonal
    // extent
    Sector sector = Sector.boundingSector(this.locations);
    // Compute padding
    double minCosLat = Math.min(sector.getMinLatitude().cos(), sector.getMaxLatitude().cos());
    minCosLat = Math.max(minCosLat, .01); // avoids division by zero at the poles
    Rectangle2D iconDimension = this.computeDrawDimension(dc, sector.getCentroid());
    double diagonalLength =
        Math.sqrt(
            iconDimension.getWidth() * iconDimension.getWidth()
                + iconDimension.getHeight() * iconDimension.getHeight());
    double padLatRadians = diagonalLength / 2 / dc.getGlobe().getRadius();
    double padLonRadians = diagonalLength / 2 / dc.getGlobe().getRadius() / minCosLat;
    // Apply padding to sector
    Angle minLat = sector.getMinLatitude().subtractRadians(padLatRadians);
    Angle maxLat = sector.getMaxLatitude().addRadians(padLatRadians);
    Angle minLon = sector.getMinLongitude().subtractRadians(padLonRadians);
    Angle maxLon = sector.getMaxLongitude().addRadians(padLatRadians);

    return this.computeNormalizedSectors(new Sector(minLat, maxLat, minLon, maxLon));
  }
 /** @see prefuse.render.Renderer#setBounds(prefuse.visual.VisualItem) */
 @Override
 public void setBounds(VisualItem item) {
   if (!m_manageBounds) {
     return;
   }
   Shape shape = getShape(item);
   if (shape == null) {
     item.setBounds(item.getX(), item.getY(), 0, 0);
   } else if (shape == m_line) {
     GraphicsLib.setBounds(item, shape, getStroke(item));
   } else {
     m_box.add(m_line.getX1(), m_line.getY1());
     m_box.add(m_line.getX2(), m_line.getY2());
     item.setBounds(m_box.getMinX(), m_box.getMinY(), m_box.getWidth(), m_box.getHeight());
   }
 }
 @Override
 public Rectangle2D.Double getDrawingArea() {
   if (cachedDrawingArea == null) {
     Rectangle2D rx = getBounds();
     Rectangle2D.Double r =
         (rx instanceof Rectangle2D.Double)
             ? (Rectangle2D.Double) rx
             : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight());
     double g = SVGAttributeKeys.getPerpendicularHitGrowth(this);
     Geom.grow(r, g, g);
     if (TRANSFORM.get(this) == null) {
       cachedDrawingArea = r;
     } else {
       cachedDrawingArea = new Rectangle2D.Double();
       cachedDrawingArea.setRect(TRANSFORM.get(this).createTransformedShape(r).getBounds2D());
     }
   }
   return (Rectangle2D.Double) cachedDrawingArea.clone();
 }
Exemple #7
0
 /** Gets the drawing area without taking the decorator into account. */
 @Override
 protected Rectangle2D.Double getFigureDrawingArea() {
   if (getText() == null) {
     return getBounds();
   } else {
     TextLayout layout = getTextLayout();
     Rectangle2D.Double r =
         new Rectangle2D.Double(origin.x, origin.y, layout.getAdvance(), layout.getAscent());
     Rectangle2D lBounds = layout.getBounds();
     if (!lBounds.isEmpty() && !Double.isNaN(lBounds.getX())) {
       r.add(
           new Rectangle2D.Double(
               lBounds.getX() + origin.x,
               (lBounds.getY() + origin.y + layout.getAscent()),
               lBounds.getWidth(),
               lBounds.getHeight()));
     }
     // grow by two pixels to take antialiasing into account
     Geom.grow(r, 2d, 2d);
     return r;
   }
 }
  /**
   * Overrides Step getMark method.
   *
   * @param trackerPanel the tracker panel
   * @return the mark
   */
  protected Mark getMark(TrackerPanel trackerPanel) {
    Mark mark = marks.get(trackerPanel);
    TPoint selection = null;
    if (mark == null) {
      selection = trackerPanel.getSelectedPoint();
      Point p = null; // draws this step as "selected" shape if not null
      valid = true; // true if step is not NaN
      for (int n = 0; n < points.length; n++) {
        if (!valid) continue;
        // determine if point is valid (ie not NaN)
        valid = valid && !Double.isNaN(points[n].getX()) && !Double.isNaN(points[n].getY());
        screenPoints[n] = points[n].getScreenPosition(trackerPanel);
        // step is "selected" if trackerPanel selectedPoint is position or selectedSteps contains
        // this step
        if (valid && (selection == points[n] || trackerPanel.selectedSteps.contains(this))) {
          p = screenPoints[n];
        }
      }
      if (p == null) {
        if (footprint instanceof PositionVectorFootprint) {
          twoPoints[0] = screenPoints[0];
          twoPoints[1] = trackerPanel.getSnapPoint().getScreenPosition(trackerPanel);
          mark = footprint.getMark(twoPoints);
        } else mark = footprint.getMark(screenPoints);
      } else {
        transform.setToTranslation(p.x, p.y);
        int scale = FontSizer.getIntegerFactor();
        if (scale > 1) {
          transform.scale(scale, scale);
        }
        final Color color = footprint.getColor();
        final Shape selectedShape = transform.createTransformedShape(selectionShape);
        mark =
            new Mark() {
              public void draw(Graphics2D g, boolean highlighted) {
                g.setRenderingHint(
                    RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Paint gpaint = g.getPaint();
                g.setPaint(color);
                g.fill(selectedShape);
                g.setPaint(gpaint);
              }

              public Rectangle getBounds(boolean highlighted) {
                return selectedShape.getBounds();
              }
            };
      }
      final Mark theMark = mark;
      mark =
          new Mark() {
            public void draw(Graphics2D g, boolean highlighted) {
              if (!valid) {
                return;
              }
              theMark.draw(g, highlighted);
            }

            public Rectangle getBounds(boolean highlighted) {
              return theMark.getBounds(highlighted);
            }
          };
      marks.put(trackerPanel, mark);
      // get new text layout
      String s = ""; // $NON-NLS-1$
      VideoClip clip = trackerPanel.getPlayer().getVideoClip();
      if (clip.getStepCount() != 1) {
        s += clip.frameToStep(getFrameNumber());
      }
      if (s.length() == 0) s = " "; // $NON-NLS-1$
      TextLayout layout = new TextLayout(s, textLayoutFont, frc);
      textLayouts.put(trackerPanel, layout);
      // get layout position (bottom left corner of text)
      p = getLayoutPosition(trackerPanel);
      Rectangle bounds = layoutBounds.get(trackerPanel);
      if (bounds == null) {
        bounds = new Rectangle();
        layoutBounds.put(trackerPanel, bounds);
      }
      Rectangle2D rect = layout.getBounds();
      // set bounds (top left corner and size)
      bounds.setRect(p.x, p.y - rect.getHeight(), rect.getWidth(), rect.getHeight());
    }
    return mark;
  }