예제 #1
0
  private final List<Point2D> getPointsFrom(
      GraphSettings gInfo, Graph g, Year startYear, int nYears, int bottom) {
    // index into our data values for this particular year
    int idx = startYear.diff(g.graph.getStart().add(g.xoffset));

    // make a list of points
    // this is ok, because we know points are continuous
    List<Point2D> points = new ArrayList<Point2D>(nYears);

    // the year the plot starts
    Year plotStartYear = gInfo.getDrawBounds().getStart();
    // the adjusted range of this graph
    Range graphRange = g.getRange();
    int yearWidth = gInfo.getYearWidth();
    float unitScale = gInfo.getHundredUnitHeight() / 100.0f;

    for (int i = 0; i <= nYears; i++) {
      // skip points that don't exist
      if (!graphRange.contains(startYear.add(i))) continue;

      int value = g.graph.getRingWidthData().get(idx + i).intValue();
      int x = getXValue(g, plotStartYear, yearWidth, idx + i);
      int y = getYValue(g, unitScale, value, bottom);

      points.add(new Point2D.Float(x, y));
    }

    return points;
  }
예제 #2
0
 private final int getDataValue(Graph g, Year y) {
   int i = y.diff(g.graph.getStart().add(g.xoffset));
   return g.graph.getRingWidthData().get(i).intValue();
 }