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


Java DateTickUnitType.YEAR属性代码示例

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


在下文中一共展示了DateTickUnitType.YEAR属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setTimeSeriesRender

public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) {

        XYPlot xyplot = (XYPlot) plot;
        xyplot.setNoDataMessage(NO_DATA_MSG);
        xyplot.setInsets(new RectangleInsets(10, 10, 5, 10));

        XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();

        xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xyRenderer.setBaseShapesVisible(false);
        if (isShowData) {
            xyRenderer.setBaseItemLabelsVisible(true);
            xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
            xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
        }
        xyRenderer.setBaseShapesVisible(isShapesVisible);

        DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
        domainAxis.setAutoTickUnitSelection(false);
        DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM"));
        domainAxis.setTickUnit(dateTickUnit);

        StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
        xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);

        setXY_XAixs(xyplot);
        setXY_YAixs(xyplot);

    }
 
开发者ID:Fanping,项目名称:iveely.ml,代码行数:29,代码来源:ChartUtils.java

示例3: createChart

public Drawable createChart(final ATSCollection dataset, Dimension dimension) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            dataset.get(Attribute.TITLE),  // title
            dataset.get(Attribute.X_AXIS_LABEL), // x-axis label
            dataset.get(Attribute.Y_AXIS_LABEL),   // y-axis label
            dataset,            // data
            false,               // create legend?
            false,               // generate tooltips?
            false               // generate URLs?
        );
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(true);
    rangeAxis.setTickUnit(new NumberTickUnit(
        (Math.round(Math.floor(getMaxOutbreaks(dataset)))/20)+1, new DecimalFormat("0")));
    XYItemRenderer r = plot.getRenderer();
    r.setSeriesPaint(0, dataset.get(Attribute.SERIES_COLOR));
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    final SimpleDateFormat dateFormatter = new SimpleDateFormat("yy"); 
    axis.setDateFormatOverride(dateFormatter);
    DateTickUnit unit = new DateTickUnit(DateTickUnitType.YEAR, 1, dateFormatter);
    axis.setTickUnit(unit);
    return new JFreeChartDrawable(chart, dimension);
}
 
开发者ID:uq-eresearch,项目名称:aorra,代码行数:31,代码来源:CotsOutbreak.java

示例4: testPreviousStandardDateYearA

/**
 * A basic check for the testPreviousStandardDate() method when the
 * tick unit is 1 year.
 */
public void testPreviousStandardDateYearA() {
    MyDateAxis axis = new MyDateAxis("Year");
    Year y2006 = new Year(2006);
    Year y2007 = new Year(2007);

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

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

    DateTickUnit unit = new DateTickUnit(DateTickUnitType.YEAR, 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

示例5: testPreviousStandardDateYearB

/**
 * A basic check for the testPreviousStandardDate() method when the
 * tick unit is 10 years (just for the sake of having a multiple).
 */
public void testPreviousStandardDateYearB() {
    MyDateAxis axis = new MyDateAxis("Year");
    Year y2006 = new Year(2006);
    Year y2007 = new Year(2007);

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

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

    DateTickUnit unit = new DateTickUnit(DateTickUnitType.YEAR, 10);
    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: 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.YEAR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。