List of usage examples for org.jfree.data.time Day getMonth
public int getMonth()
From source file:org.jfree.data.time.DayTest.java
/** * Some checks for the testNext() method. *//*w ww .ja v a 2 s . c om*/ @Test public void testNext() { Day d = new Day(25, 12, 2000); d = (Day) d.next(); assertEquals(2000, d.getYear()); assertEquals(12, d.getMonth()); assertEquals(26, d.getDayOfMonth()); d = new Day(31, 12, 9999); assertNull(d.next()); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * Some checks for the testNext() method. */// ww w . ja va 2 s . c om public void testNext() { Day d = new Day(25, 12, 2000); d = (Day) d.next(); assertEquals(2000, d.getYear()); assertEquals(12, d.getMonth()); assertEquals(26, d.getDayOfMonth()); d = new Day(31, 12, 9999); assertNull(d.next()); }
From source file:org.jfree.data.time.DayTest.java
/** * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L). * Use this to check the day constructor. *///from w w w . ja va 2 s . c o m @Test public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.UK; Day d1 = new Day(new Date(1078099199999L), zone, locale); Day d2 = new Day(new Date(1078099200000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078099199999L, d1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078099200000L, d2.getFirstMillisecond(zone)); }
From source file:org.jfree.data.time.DayTest.java
/** * In Helsinki, the end of 29 Feb 2004 is * java.util.Date(1,078,091,999,999L). Use this to check the Day * constructor.//from w w w.java 2s. c o m */ @Test public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); Locale locale = Locale.getDefault(); // locale shouldn't matter here Day d1 = new Day(new Date(1078091999999L), zone, locale); Day d2 = new Day(new Date(1078092000000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078091999999L, d1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078092000000L, d2.getFirstMillisecond(zone)); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L). * Use this to check the day constructor. *//*from www .j a v a 2 s . c om*/ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Calendar c = new GregorianCalendar(zone); Locale locale = Locale.UK; Day d1 = new Day(new Date(1078099199999L), zone, locale); Day d2 = new Day(new Date(1078099200000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078099199999L, d1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078099200000L, d2.getFirstMillisecond(c)); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * In Helsinki, the end of 29 Feb 2004 is * java.util.Date(1,078,091,999,999L). Use this to check the Day * constructor.//from ww w .j a va 2 s . com */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); Calendar c = new GregorianCalendar(zone); Locale locale = Locale.getDefault(); // locale shouldn't matter here Day d1 = new Day(new Date(1078091999999L), zone, locale); Day d2 = new Day(new Date(1078092000000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078091999999L, d1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078092000000L, d2.getFirstMillisecond(c)); }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
/** * Zoom in to this chart with specific amount of time. * @param field the calendar field./*from w w w. j ava2s . c o m*/ * @param amount the amount of date or time to be added to the field. */ private void _zoom(int field, int amount) { this.chartPanel.restoreAutoBounds(); final int itemCount = this.priceTimeSeries.getItemCount(); final Day day = (Day) this.priceTimeSeries.getDataItem(itemCount - 1).getPeriod(); // Candle stick takes up half day space. // Volume price chart's volume information takes up whole day space. final long end = day.getFirstMillisecond() + (this.getCurrentType() == Type.Candlestick ? (1000 * 60 * 60 * 12) : (1000 * 60 * 60 * 24 - 1)); final Calendar calendar = Calendar.getInstance(); // -1. Calendar's month is 0 based but JFreeChart's month is 1 based. calendar.set(day.getYear(), day.getMonth() - 1, day.getDayOfMonth(), 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(field, amount); // Candle stick takes up half day space. // Volume price chart's volume information does not take up any space. final long start = Math.max(0, calendar.getTimeInMillis() - (this.getCurrentType() == Type.Candlestick ? (1000 * 60 * 60 * 12) : 0)); final ValueAxis valueAxis = this.getPlot().getDomainAxis(); if (priceTimeSeries.getItemCount() > 0) { if (start < priceTimeSeries.getTimePeriod(0).getFirstMillisecond()) { // To prevent zoom-out too much. // This happens when user demands for 10 years zoom, where we // are only having 5 years data. return; } } valueAxis.setRange(start, end); double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; double max_volume = Double.MIN_VALUE; final DefaultHighLowDataset defaultHighLowDataset = (DefaultHighLowDataset) this.priceOHLCDataset; for (int i = itemCount - 1; i >= 0; i--) { final TimeSeriesDataItem item = this.priceTimeSeries.getDataItem(i); final Day d = (Day) item.getPeriod(); if (d.getFirstMillisecond() < start) { break; } final double high = defaultHighLowDataset.getHighValue(0, i); final double low = defaultHighLowDataset.getLowValue(0, i); final double volume = defaultHighLowDataset.getVolumeValue(0, i); if (max < high) { max = high; } if (min > low) { min = low; } if (max_volume < volume) { max_volume = volume; } } if (min > max) { return; } final ValueAxis rangeAxis = this.getPlot().getRangeAxis(); final Range rangeAxisRange = rangeAxis.getRange(); // Increase each side by 1% double tolerance = 0.01 * (max - min); // The tolerance must within range [0.01, 1.0] tolerance = Math.min(Math.max(0.01, tolerance), 1.0); // The range must within the original chart range. min = Math.max(rangeAxisRange.getLowerBound(), min - tolerance); max = Math.min(rangeAxisRange.getUpperBound(), max + tolerance); this.getPlot().getRangeAxis().setRange(min, max); if (this.getPlot().getRangeAxisCount() > 1) { final double volumeUpperBound = this.getPlot().getRangeAxis(1).getRange().getUpperBound(); final double suggestedVolumneUpperBound = max_volume * 4; // To prevent over zoom-in. if (suggestedVolumneUpperBound < volumeUpperBound) { this.getPlot().getRangeAxis(1).setRange(0, suggestedVolumneUpperBound); } } }