Example #1
0
        public void PolarPlot_Constructor_Initialises_To_Known_Values_And_Properties_Work()
        {
            var plot = new PolarPlot();

            TestUtilities.TestProperty(plot, r => r.Altitude, 0, int.MaxValue);
            TestUtilities.TestProperty(plot, r => r.Angle, 0, int.MinValue);
            TestUtilities.TestProperty(plot, r => r.Distance, 0.0, double.MaxValue);
            TestUtilities.TestProperty(plot, r => r.Latitude, 0.0, double.MinValue);
            TestUtilities.TestProperty(plot, r => r.Longitude, 0.0, double.MaxValue);
        }
Example #2
0
        /// <summary>
        /// Creates a new <see cref="PolarPlotJson"/> from an aircraft list's <see cref="PolarPlot"/>.
        /// </summary>
        /// <param name="polarPlot"></param>
        /// <returns></returns>
        public static PolarPlotJson ToModel(PolarPlot polarPlot)
        {
            PolarPlotJson result = null;

            if (polarPlot != null)
            {
                result = new PolarPlotJson()
                {
                    Latitude  = (float)polarPlot.Latitude,
                    Longitude = (float)polarPlot.Longitude,
                };
            }

            return(result);
        }
Example #3
0
        public void PolarPlot_Clone_Copies_All_Properties()
        {
            foreach (var property in typeof(PolarPlot).GetProperties())
            {
                var original = new PolarPlot();
                TestUtilities.AssignPropertyValue(original, property, true);
                var copy = original.Clone();

                foreach (var compareProperty in typeof(PolarPlot).GetProperties())
                {
                    var originalValue = compareProperty.GetValue(original, null);
                    var newValue      = compareProperty.GetValue(copy, null);
                    Assert.AreEqual(originalValue, newValue, compareProperty.Name);
                }
            }
        }
Example #4
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="aircraftId"></param>
        /// <param name="altitude"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        public void AddCheckedCoordinate(int aircraftId, int altitude, double latitude, double longitude)
        {
            if (RoundToDegrees > 0)
            {
                var distance    = GreatCircleMaths.Distance(Latitude, Longitude, latitude, longitude);
                var fullBearing = GreatCircleMaths.Bearing(Latitude, Longitude, latitude, longitude, null, false, true);

                if (distance != null && fullBearing != null && distance <= _ReceiverRange)
                {
                    var roundedBearing = RoundBearing(fullBearing.Value);

                    lock (_SyncLock) {
                        foreach (var slice in _Slices)
                        {
                            if (slice.AltitudeLower <= altitude && slice.AltitudeHigher >= altitude)
                            {
                                PolarPlot plot;
                                if (!slice.PolarPlots.TryGetValue(roundedBearing, out plot))
                                {
                                    plot = new PolarPlot();
                                    slice.PolarPlots.Add(roundedBearing, plot);
                                }
                                if (distance >= plot.Distance)
                                {
                                    plot.Altitude  = altitude;
                                    plot.Angle     = roundedBearing;
                                    plot.Distance  = distance.Value;
                                    plot.Latitude  = latitude;
                                    plot.Longitude = longitude;
                                }
                            }
                        }
                    }
                }
            }
        }
 public virtual void setPlot(PolarPlot plot)
 {
   this.plot = plot;
 }
 public virtual void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea)
 {
   ((Graphics) g2).setFont(radialAxis.getTickLabelFont());
   g2.setPaint(plot.getRadiusGridlinePaint());
   g2.setStroke(plot.getRadiusGridlineStroke());
   double lowerBound = radialAxis.getLowerBound();
   Point point = plot.translateValueThetaRadiusToJava2D(lowerBound, lowerBound, dataArea);
   Iterator iterator = ticks.iterator();
   while (iterator.hasNext())
   {
     NumberTick numberTick = (NumberTick) iterator.next();
     int num1 = (int) (plot.translateValueThetaRadiusToJava2D(90.0, numberTick.getNumber().doubleValue(), dataArea).x - point.x);
     int num2 = point.x - num1;
     int num3 = point.y - num1;
     int num4 = 2 * num1;
     Ellipse2D.Double @double = new Ellipse2D.Double((double) num2, (double) num3, (double) num4, (double) num4);
     g2.setPaint(plot.getRadiusGridlinePaint());
     g2.draw((Shape) @double);
   }
 }
 public virtual void drawAngularGridLines(Graphics2D g2, PolarPlot plot, List ticks, Rectangle2D dataArea)
 {
   ((Graphics) g2).setFont(plot.getAngleLabelFont());
   g2.setStroke(plot.getAngleGridlineStroke());
   g2.setPaint(plot.getAngleGridlinePaint());
   double lowerBound = plot.getAxis().getLowerBound();
   double maxRadius = plot.getMaxRadius();
   Point point1 = plot.translateValueThetaRadiusToJava2D(lowerBound, lowerBound, dataArea);
   Iterator iterator = ticks.iterator();
   while (iterator.hasNext())
   {
     NumberTick numberTick = (NumberTick) iterator.next();
     Point point2 = plot.translateValueThetaRadiusToJava2D(numberTick.getNumber().doubleValue(), maxRadius, dataArea);
     g2.setPaint(plot.getAngleGridlinePaint());
     ((Graphics) g2).drawLine((int) point1.x, (int) point1.y, (int) point2.x, (int) point2.y);
     if (plot.isAngleLabelsVisible())
     {
       int num1 = (int) point2.x;
       int num2 = (int) point2.y;
       g2.setPaint(plot.getAngleLabelPaint());
       TextUtilities.drawAlignedString(numberTick.getText(), g2, (float) num1, (float) num2, TextAnchor.__\u003C\u003ECENTER);
     }
   }
 }
 public virtual void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex)
 {
   Polygon polygon = new Polygon();
   int itemCount = dataset.getItemCount(seriesIndex);
   for (int i2 = 0; i2 < itemCount; ++i2)
   {
     double xvalue = dataset.getXValue(seriesIndex, i2);
     double yvalue = dataset.getYValue(seriesIndex, i2);
     Point point = plot.translateValueThetaRadiusToJava2D(xvalue, yvalue, dataArea);
     polygon.addPoint((int) point.x, (int) point.y);
   }
   g2.setPaint(this.lookupSeriesPaint(seriesIndex));
   g2.setStroke(this.lookupSeriesStroke(seriesIndex));
   if (this.isSeriesFilled(seriesIndex))
   {
     Composite composite = g2.getComposite();
     g2.setComposite((Composite) AlphaComposite.getInstance(3, 0.5f));
     g2.fill((Shape) polygon);
     g2.setComposite(composite);
   }
   else
     g2.draw((Shape) polygon);
 }
Example #9
0
 public static JFreeChart createPolarChart(string title, XYDataset dataset, bool legend, bool tooltips, bool urls)
 {
   int num = legend ? 1 : 0;
   PolarPlot polarPlot = new PolarPlot();
   polarPlot.setDataset(dataset);
   NumberAxis numberAxis = new NumberAxis();
   numberAxis.setAxisLineVisible(false);
   numberAxis.setTickMarksVisible(false);
   numberAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
   polarPlot.setAxis((ValueAxis) numberAxis);
   polarPlot.setRenderer((PolarItemRenderer) new DefaultPolarItemRenderer());
   JFreeChart.__\u003Cclinit\u003E();
   JFreeChart jfc = new JFreeChart(title, JFreeChart.__\u003C\u003EDEFAULT_TITLE_FONT, (Plot) polarPlot, num != 0);
   ChartFactory.currentTheme.apply(jfc);
   return jfc;
 }