예제 #1
0
  /** Test that the setMinimumDate() method works. */
  @Test
  public void testSetMinimumDate() {
    DateAxis axis = new DateAxis("Test Axis");
    Date d1 = new Date();
    Date d2 = new Date(d1.getTime() + 1);
    axis.setMaximumDate(d2);
    axis.setMinimumDate(d1);
    assertEquals(d1, axis.getMinimumDate());

    // check that setting the min date to something on or after the
    // current min date works...
    Date d3 = new Date(d2.getTime() + 1);
    axis.setMinimumDate(d2);
    assertEquals(d3, axis.getMaximumDate());
  }
예제 #2
0
  /** Test that the setMaximumDate() method works. */
  @Test
  public void testSetMaximumDate() {
    DateAxis axis = new DateAxis("Test Axis");
    Date date = new Date();
    axis.setMaximumDate(date);
    assertEquals(date, axis.getMaximumDate());

    // check that setting the max date to something on or before the
    // current min date works...
    Date d1 = new Date();
    Date d2 = new Date(d1.getTime() + 1);
    Date d0 = new Date(d1.getTime() - 1);
    axis.setMaximumDate(d2);
    axis.setMinimumDate(d1);
    axis.setMaximumDate(d1);
    assertEquals(d0, axis.getMinimumDate());
  }
예제 #3
0
  @Test
  public void testBug3484403() {

    final long[] dates = {
      1304892000000L,
      1304632800000L,
      1304546400000L,
      1304460000000L,
      1304373600000L,
      1304287200000L,
      1320015600000L,
      1309384800000L,
      1319752800000L,
      1319666400000L,
      1319580000000L,
      1319493600000L
    };
    Arrays.sort(dates);

    DateAxis axis = new DateAxis("Date");
    // set start and end date
    Date start = new Date(dates[0]);
    Date end = new Date(dates[dates.length - 1]);
    axis.setMinimumDate(start);
    axis.setMaximumDate(end);

    SegmentedTimeline timeline = SegmentedTimeline.newMondayThroughFridayTimeline();
    timeline.setStartTime(start.getTime());
    axis.setTimeline(timeline);

    BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 500, 200);

    // if the bug is still present, this leads to an endless loop
    axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.BOTTOM);
  }