当前位置: 首页>>代码示例>>Java>>正文


Java DateTickUnitType.DAY属性代码示例

本文整理汇总了Java中org.jfree.chart.axis.DateTickUnitType.DAY属性的典型用法代码示例。如果您正苦于以下问题:Java DateTickUnitType.DAY属性的具体用法?Java DateTickUnitType.DAY怎么用?Java DateTickUnitType.DAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.jfree.chart.axis.DateTickUnitType的用法示例。


在下文中一共展示了DateTickUnitType.DAY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTimePeriodUnit

/**
 * Returns the specific org.jfree.chart.axis.DateTickUnit time unit constant
 * related to the String value passed as argument
 * 
 * @param timePeriodUnit - a String represented by one of the following
 * accepted values: ["Year", "Month", "Day", "Hour", "Minute", "Second", "Millisecond"]
 * @return the specific org.jfree.chart.axis.DateTickUnit time unit constant
 */
protected DateTickUnitType getTimePeriodUnit(String timePeriodUnit)
{
	if (timePeriodUnit == null)
		return DateTickUnitType.DAY;
	return timePeriodUnit.equals("Year")
		? DateTickUnitType.YEAR
		: timePeriodUnit.equals("Month")
		? DateTickUnitType.MONTH
		: timePeriodUnit.equals("Hour")
		? DateTickUnitType.HOUR
		: timePeriodUnit.equals("Minute")
		? DateTickUnitType.MINUTE
		: timePeriodUnit.equals("Second")
		? DateTickUnitType.SECOND
		: timePeriodUnit.equals("Millisecond")
		? DateTickUnitType.MILLISECOND
		: DateTickUnitType.DAY;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:26,代码来源:GenericChartTheme.java

示例2: FixedDateTickUnit

/** Constructor. */
private FixedDateTickUnit() {
	super(DateTickUnitType.DAY, 1);

	Calendar c = Calendar.getInstance();
	Date today = DateUtils.getNow();

	c.setTime(today);
	tickDates.add(c.getTime());

	c.setTime(today);
	c.add(Calendar.DAY_OF_MONTH, -2);
	tickDates.add(c.getTime());

	c.setTime(today);
	c.add(Calendar.DAY_OF_MONTH, -7);
	tickDates.add(c.getTime());

	c.setTime(today);
	c.add(Calendar.MONTH, -1);
	tickDates.add(c.getTime());
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:22,代码来源:SeriesCreatorBase.java

示例3: testHashCode

/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashCode() {
    DateTickUnit t1 = new DateTickUnit(DateTickUnitType.DAY, 1);
    DateTickUnit t2 = new DateTickUnit(DateTickUnitType.DAY, 1);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:DateTickUnitTests.java

示例4: getDateTickUnit

private DateTickUnit getDateTickUnit(final TimeGranularity timeGranularity,
    final long windowMillis) {
  long windowBuckets = timeGranularity.convertToUnit(windowMillis);
  int tickSize = (int) Math.ceil(windowBuckets / (double) NUM_X_TICKS);
  DateTickUnitType unitType;
  switch (timeGranularity.getUnit()) {
  case DAYS:
    unitType = DateTickUnitType.DAY;
    break;
  case HOURS:
    unitType = DateTickUnitType.HOUR;
    break;
  case MILLISECONDS:
    unitType = DateTickUnitType.MILLISECOND;
    break;
  case MINUTES:
    unitType = DateTickUnitType.MINUTE;
    break;
  case SECONDS:
    unitType = DateTickUnitType.SECOND;
    break;
  default:
    throw new IllegalArgumentException(
        "Unsupported time unit granularity: " + timeGranularity.getUnit());
  }
  return new DateTickUnit(unitType, tickSize);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:27,代码来源:AnomalyGraphGenerator.java

示例5: testPreviousStandardDateDayA

/**
 * A basic check for the testPreviousStandardDate() method when the
 * tick unit is 1 day.
 */
public void testPreviousStandardDateDayA() {
    MyDateAxis axis = new MyDateAxis("Day");
    Day apr12007 = new Day(1, 4, 2007);
    Day apr22007 = new Day(2, 4, 2007);

    // five dates to check...
    Date d0 = new Date(apr12007.getFirstMillisecond());
    Date d1 = new Date(apr12007.getFirstMillisecond() + 500L);
    Date d2 = new Date(apr12007.getMiddleMillisecond());
    Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L);
    Date d4 = new Date(apr12007.getLastMillisecond());

    Date end = new Date(apr22007.getLastMillisecond());

    DateTickUnit unit = new DateTickUnit(DateTickUnitType.DAY, 1);
    axis.setTickUnit(unit);

    // START: check d0 and d1
    axis.setTickMarkPosition(DateTickMarkPosition.START);

    axis.setRange(d0, end);
    Date psd = axis.previousStandardDate(d0, unit);
    Date nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d0.getTime());
    assertTrue(nsd.getTime() >= d0.getTime());

    axis.setRange(d1, end);
    psd = axis.previousStandardDate(d1, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d1.getTime());
    assertTrue(nsd.getTime() >= d1.getTime());

    // MIDDLE: check d1, d2 and d3
    axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    axis.setRange(d1, end);
    psd = axis.previousStandardDate(d1, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d1.getTime());
    assertTrue(nsd.getTime() >= d1.getTime());

    axis.setRange(d2, end);
    psd = axis.previousStandardDate(d2, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d2.getTime());
    assertTrue(nsd.getTime() >= d2.getTime());

    axis.setRange(d3, end);
    psd = axis.previousStandardDate(d3, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d3.getTime());
    assertTrue(nsd.getTime() >= d3.getTime());

    // END: check d3 and d4
    axis.setTickMarkPosition(DateTickMarkPosition.END);

    axis.setRange(d3, end);
    psd = axis.previousStandardDate(d3, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d3.getTime());
    assertTrue(nsd.getTime() >= d3.getTime());

    axis.setRange(d4, end);
    psd = axis.previousStandardDate(d4, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d4.getTime());
    assertTrue(nsd.getTime() >= d4.getTime());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:72,代码来源:DateAxisTests.java

示例6: testPreviousStandardDateDayB

/**
 * A basic check for the testPreviousStandardDate() method when the
 * tick unit is 7 days (just for the sake of having a multiple).
 */
public void testPreviousStandardDateDayB() {
    MyDateAxis axis = new MyDateAxis("Day");
    Day apr12007 = new Day(1, 4, 2007);
    Day apr22007 = new Day(2, 4, 2007);

    // five dates to check...
    Date d0 = new Date(apr12007.getFirstMillisecond());
    Date d1 = new Date(apr12007.getFirstMillisecond() + 500L);
    Date d2 = new Date(apr12007.getMiddleMillisecond());
    Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L);
    Date d4 = new Date(apr12007.getLastMillisecond());

    Date end = new Date(apr22007.getLastMillisecond());

    DateTickUnit unit = new DateTickUnit(DateTickUnitType.DAY, 7);
    axis.setTickUnit(unit);

    // START: check d0 and d1
    axis.setTickMarkPosition(DateTickMarkPosition.START);

    axis.setRange(d0, end);
    Date psd = axis.previousStandardDate(d0, unit);
    Date nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d0.getTime());
    assertTrue(nsd.getTime() >= d0.getTime());

    axis.setRange(d1, end);
    psd = axis.previousStandardDate(d1, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d1.getTime());
    assertTrue(nsd.getTime() >= d1.getTime());

    // MIDDLE: check d1, d2 and d3
    axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    axis.setRange(d1, end);
    psd = axis.previousStandardDate(d1, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d1.getTime());
    assertTrue(nsd.getTime() >= d1.getTime());

    axis.setRange(d2, end);
    psd = axis.previousStandardDate(d2, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d2.getTime());
    assertTrue(nsd.getTime() >= d2.getTime());

    axis.setRange(d3, end);
    psd = axis.previousStandardDate(d3, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d3.getTime());
    assertTrue(nsd.getTime() >= d3.getTime());

    // END: check d3 and d4
    axis.setTickMarkPosition(DateTickMarkPosition.END);

    axis.setRange(d3, end);
    psd = axis.previousStandardDate(d3, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d3.getTime());
    assertTrue(nsd.getTime() >= d3.getTime());

    axis.setRange(d4, end);
    psd = axis.previousStandardDate(d4, unit);
    nsd = unit.addToDate(psd, TimeZone.getDefault());
    assertTrue(psd.getTime() < d4.getTime());
    assertTrue(nsd.getTime() >= d4.getTime());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:72,代码来源:DateAxisTests.java

示例7: testEquals

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    DateTickUnit t1 = new DateTickUnit(DateTickUnitType.DAY, 1);
    DateTickUnit t2 = new DateTickUnit(DateTickUnitType.DAY, 1);
    assertTrue(t1.equals(t2));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:DateTickUnitTests.java

示例8: createChart

private void createChart(UsageDataFrame points, String title) {
    series = new TimeSeries(title);

    for (UsageData d : points.getData()) {
        Date resultdate = d.getDateTime();
        Millisecond msRead = new Millisecond(resultdate);
        int poweredValue = -1;
        if (d.getObjBehavior().equalsIgnoreCase("powered")) {
            poweredValue = d.getObjValue().equalsIgnoreCase("true") ? 1 : 0;
        } else if (d.getObjBehavior().equalsIgnoreCase("brigthness")) {
            try {
                poweredValue = Integer.parseInt(d.getObjValue());
            } catch (NumberFormatException ex) {
                poweredValue = -1;
            }
        }
        series.addOrUpdate(msRead, poweredValue);
    }

    XYDataset xyDataset = new TimeSeriesCollection(series);

    chart = ChartFactory.createTimeSeriesChart("Chart",
            "TIME", "VALUE",
            xyDataset,
            true, // legend
            true, // tooltips
            false // urls
    );
    chart.setAntiAlias(true);
    // Set plot styles
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    // Set series line styles
    plot.setRenderer(new XYStepRenderer());

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setShapesVisible(true);
        renderer.setShapesFilled(true);
    }

    // Set date axis style
    DateAxis axis = (DateAxis) plot.getDomainAxis();

    String formatString = "MM-dd HH";
    DateTickUnitType dtut = DateTickUnitType.HOUR;

    if (jComboGranularity.getSelectedItem().equals("Year")) {
        formatString = "yyyy";
        dtut = DateTickUnitType.YEAR;
    } else if (jComboGranularity.getSelectedItem().equals("Month")) {
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));
        dtut = DateTickUnitType.MONTH;
    } else if (jComboGranularity.getSelectedItem().equals("Day")) {
        axis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));
        dtut = DateTickUnitType.DAY;
    } else if (jComboGranularity.getSelectedItem().equals("Minute")) {
        formatString = "MM-dd HH:mm";
        dtut = DateTickUnitType.MINUTE;
    } else if (jComboGranularity.getSelectedItem().equals("Second")) {
        formatString = "HH:mm:SS";
        dtut = DateTickUnitType.SECOND;
    }

    DateFormat formatter = new SimpleDateFormat(formatString);
    DateTickUnit unit = new DateTickUnit(dtut, 1, formatter);
    axis.setTickUnit(unit);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 500));
    graphPanel.removeAll();
    graphPanel.add(chartPanel);

}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:78,代码来源:GraphPanel.java


注:本文中的org.jfree.chart.axis.DateTickUnitType.DAY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。