List of usage examples for org.jfree.data.time Day getSerialDate
public SerialDate getSerialDate()
From source file:grafix.graficos.ConstrutorGrafico.java
private void configurarEixoHorizontal(DateAxis domainAxis) { if (janela.getIntervaloExibicao().isEspacoPrevisao()) { Day ultimoDia = janela.getAcao().getData(janela.getAcao().getNumeroRegistros() - 1, Controle.getConfiguracoesUsuario().isExibeSomenteDiasUteis()); Day ultimoDiaPrevisao = (Day) ultimoDia.next(); for (int i = 0; i < Controle.getConfiguracoesGrafix().getEspacoPrevisao() - 1; i++) { ultimoDiaPrevisao = (Day) ultimoDiaPrevisao.next(); }//from www . j a va 2s. co m domainAxis.setMaximumDate(ultimoDiaPrevisao.getSerialDate().toDate()); } }
From source file:org.jfree.data.time.DayTest.java
/** * Problem for date parsing.//from w w w . ja v a 2s . c om * <p> * This test works only correct if the short pattern of the date * format is "dd/MM/yyyy". If not, this test will result in a * false negative. * * @throws ParseException on parsing errors. */ @Test public void testParseDay() throws ParseException { GregorianCalendar gc = new GregorianCalendar(2001, 12, 31); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); Date reference = format.parse("31/12/2001"); if (reference.equals(gc.getTime())) { // test 1... Day d = Day.parseDay("31/12/2001"); assertEquals(37256, d.getSerialDate().toSerial()); } // test 2... Day d = Day.parseDay("2001-12-31"); assertEquals(37256, d.getSerialDate().toSerial()); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * Problem for date parsing.//from w w w.ja va 2 s. co m * <p> * This test works only correct if the short pattern of the date * format is "dd/MM/yyyy". If not, this test will result in a * false negative. * * @throws ParseException on parsing errors. */ public void testParseDay() throws ParseException { GregorianCalendar gc = new GregorianCalendar(2001, 12, 31); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); Date reference = format.parse("31/12/2001"); if (reference.equals(gc.getTime())) { // test 1... Day d = Day.parseDay("31/12/2001"); assertEquals(37256, d.getSerialDate().toSerial()); } // test 2... Day d = Day.parseDay("2001-12-31"); assertEquals(37256, d.getSerialDate().toSerial()); }
From source file:org.jfree.data.time.Day.java
/** * Returns an integer indicating the order of this Day object relative to * the specified object:/*from www. j a v a2s . co m*/ * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ @Override public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Day object // ---------------------------------------- if (o1 instanceof Day) { Day d = (Day) o1; result = -d.getSerialDate().compare(this.serialDate); } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; }
From source file:org.jfree.data.time.Day.java
/** * Tests the equality of this Day object to an arbitrary object. Returns * true if the target is a Day instance or a SerialDate instance * representing the same day as this object. In all other cases, * returns false.//from w w w.java 2 s. c o m * * @param obj the object (<code>null</code> permitted). * * @return A flag indicating whether or not an object is equal to this day. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Day)) { return false; } Day that = (Day) obj; if (!this.serialDate.equals(that.getSerialDate())) { return false; } return true; }
From source file:org.jfree.chart.demo.TimeSeriesDemo11.java
/** * A demonstration application showing how to... * * @param title the frame title./* w ww . j a v a2 s . com*/ */ public TimeSeriesDemo11(final String title) { super(title); final JPanel panel = new JPanel(new GridLayout(2, 2)); panel.setPreferredSize(new java.awt.Dimension(800, 600)); final Day today = new Day(); final XYDataset dataset = createDataset("Series 1", 100.0, today, 365); final JFreeChart chart1 = createChart("Chart 1 : 1 Year", dataset); final ChartPanel chartPanel1 = new ChartPanel(chart1); panel.add(chartPanel1); final JFreeChart chart2 = createChart("Chart 2 : 6 Months", dataset); final SerialDate t = today.getSerialDate(); final SerialDate t6m = SerialDate.addMonths(-6, t); final Day sixMonthsAgo = new Day(t6m); final DateAxis axis2 = (DateAxis) chart2.getXYPlot().getDomainAxis(); axis2.setRange(sixMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel2 = new ChartPanel(chart2); panel.add(chartPanel2); final JFreeChart chart3 = createChart("Chart 3 : 3 Months", dataset); final SerialDate t3m = SerialDate.addMonths(-3, t); final Day threeMonthsAgo = new Day(t3m); final DateAxis axis3 = (DateAxis) chart3.getXYPlot().getDomainAxis(); axis3.setRange(threeMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel3 = new ChartPanel(chart3); panel.add(chartPanel3); final JFreeChart chart4 = createChart("Chart 4 : 1 Month", dataset); final SerialDate t1m = SerialDate.addMonths(-1, t); final Day oneMonthsAgo = new Day(t1m); final DateAxis axis4 = (DateAxis) chart4.getXYPlot().getDomainAxis(); axis4.setRange(oneMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel4 = new ChartPanel(chart4); panel.add(chartPanel4); setContentPane(panel); }