List of usage examples for org.jfree.data.time TimePeriodAnchor START
TimePeriodAnchor START
To view the source code for org.jfree.data.time TimePeriodAnchor START.
Click Source Link
From source file:org.jfree.data.time.TimePeriodAnchorTest.java
/** * Test the equals() method.//from w w w . ja va 2 s . com */ @Test public void testEquals() { assertTrue(TimePeriodAnchor.START.equals(TimePeriodAnchor.START)); assertTrue(TimePeriodAnchor.MIDDLE.equals(TimePeriodAnchor.MIDDLE)); assertTrue(TimePeriodAnchor.END.equals(TimePeriodAnchor.END)); }
From source file:org.jfree.data.time.TimePeriodAnchorTest.java
/** * Serialize an instance, restore it, and check for identity. *///from w ww. j a va2s. com @Test public void testSerialization() { TimePeriodAnchor a1 = TimePeriodAnchor.START; TimePeriodAnchor a2 = (TimePeriodAnchor) TestUtilities.serialised(a1); assertTrue(a1 == a2); }
From source file:org.jfree.data.time.TimeTableXYDataset.java
/** * Creates a new dataset with the given time zone and locale. * * @param zone the time zone to use (<code>null</code> not permitted). * @param locale the locale to use (<code>null</code> not permitted). *//* w w w.ja v a 2s .c o m*/ public TimeTableXYDataset(TimeZone zone, Locale locale) { ParamChecks.nullNotPermitted(zone, "zone"); ParamChecks.nullNotPermitted(locale, "locale"); this.values = new DefaultKeyedValues2D(true); this.workingCalendar = Calendar.getInstance(zone, locale); this.xPosition = TimePeriodAnchor.START; }
From source file:org.jfree.data.time.ohlc.OHLCSeriesCollection.java
/** * Returns the x-value for a time period. * * @param period the time period (<code>null</code> not permitted). * * @return The x-value./*from w ww . jav a 2s . c om*/ */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(); } return result; }
From source file:org.jfree.data.time.TimePeriodValuesCollection.java
/** * Returns the x-value for a time period. * * @param period the time period.//from w w w . j a v a2s .c o m * * @return The x-value. */ private long getX(TimePeriod period) { if (this.xPosition == TimePeriodAnchor.START) { return period.getStart().getTime(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { return period.getStart().getTime() / 2 + period.getEnd().getTime() / 2; } else if (this.xPosition == TimePeriodAnchor.END) { return period.getEnd().getTime(); } else { throw new IllegalStateException("TimePeriodAnchor unknown."); } }
From source file:edu.dlnu.liuwenpeng.Time.TimeSeriesCollection.java
/** * Constructs a dataset containing a single series (more can be added), * tied to a specific timezone. //w w w . j a v a2 s .com * * @param series a series to add to the collection (<code>null</code> * permitted). * @param zone the timezone (<code>null</code> permitted, will use * <code>TimeZone.getDefault()</code> in that case). */ public TimeSeriesCollection(TimeSeries series, TimeZone zone) { if (zone == null) { zone = TimeZone.getDefault(); } this.workingCalendar = Calendar.getInstance(zone); this.data = new ArrayList(); if (series != null) { this.data.add(series); series.addChangeListener(this); } this.xPosition = TimePeriodAnchor.START; this.domainIsPointsInTime = true; }
From source file:org.jfree.data.time.TimeSeriesCollection.java
/** * Constructs a dataset containing a single series (more can be added), * tied to a specific timezone./* ww w . j a va 2 s. com*/ * * @param series a series to add to the collection (<code>null</code> * permitted). * @param zone the timezone (<code>null</code> permitted, will use * <code>TimeZone.getDefault()</code> in that case). */ public TimeSeriesCollection(TimeSeries series, TimeZone zone) { // FIXME: need a locale as well as a timezone if (zone == null) { zone = TimeZone.getDefault(); } this.workingCalendar = Calendar.getInstance(zone); this.data = new ArrayList(); if (series != null) { this.data.add(series); series.addChangeListener(this); } this.xPosition = TimePeriodAnchor.START; this.domainIsPointsInTime = true; }
From source file:ch.algotrader.client.chart.ChartTab.java
private void initOHLCSeries(int datasetNumber, XYDataset dataset, SeriesDefinitionVO seriesDefinition) { BarDefinitionVO barDefinition = (BarDefinitionVO) seriesDefinition; OHLCSeriesCollection ohlcSeriesCollection = (OHLCSeriesCollection) dataset; ohlcSeriesCollection.setXPosition(TimePeriodAnchor.START); // create the TimeSeries OHLCSeries series = new OHLCSeries(barDefinition.getLabel()); ohlcSeriesCollection.addSeries(series); this.bars.put(barDefinition.getSecurityId(), series); // get the seriesNumber & color final int seriesNumber = ohlcSeriesCollection.getSeriesCount() - 1; // configure the renderer final CandlestickRenderer renderer = (CandlestickRenderer) getPlot().getRenderer(datasetNumber); renderer.setSeriesPaint(seriesNumber, getColor(barDefinition.getColor())); renderer.setSeriesVisible(seriesNumber, seriesDefinition.isSelected()); renderer.setAutoWidthMethod(HideableCandlestickRenderer.WIDTHMETHOD_SMALLEST); // add the menu item JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel()); menuItem.setSelected(seriesDefinition.isSelected()); menuItem.addActionListener(new ActionListener() { @Override// ww w . jav a 2 s . c o m public void actionPerformed(ActionEvent e) { resetAxis(); renderer.setSeriesVisible(seriesNumber, ((JCheckBoxMenuItem) e.getSource()).isSelected(), true); initAxis(); } }); this.getPopupMenu().add(menuItem); }
From source file:org.jfree.data.time.TimePeriodValuesCollection.java
/** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range.//from w w w. j a va2 s . c o m */ @Override public Range getDomainBounds(boolean includeInterval) { boolean interval = includeInterval || this.domainIsPointsInTime; Range result = null; Range temp = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimePeriodValues series = (TimePeriodValues) iterator.next(); int count = series.getItemCount(); if (count > 0) { TimePeriod start = series.getTimePeriod(series.getMinStartIndex()); TimePeriod end = series.getTimePeriod(series.getMaxEndIndex()); if (!interval) { if (this.xPosition == TimePeriodAnchor.START) { TimePeriod maxStart = series.getTimePeriod(series.getMaxStartIndex()); temp = new Range(start.getStart().getTime(), maxStart.getStart().getTime()); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { TimePeriod minMiddle = series.getTimePeriod(series.getMinMiddleIndex()); long s1 = minMiddle.getStart().getTime(); long e1 = minMiddle.getEnd().getTime(); TimePeriod maxMiddle = series.getTimePeriod(series.getMaxMiddleIndex()); long s2 = maxMiddle.getStart().getTime(); long e2 = maxMiddle.getEnd().getTime(); temp = new Range(s1 + (e1 - s1) / 2, s2 + (e2 - s2) / 2); } else if (this.xPosition == TimePeriodAnchor.END) { TimePeriod minEnd = series.getTimePeriod(series.getMinEndIndex()); temp = new Range(minEnd.getEnd().getTime(), end.getEnd().getTime()); } } else { temp = new Range(start.getStart().getTime(), end.getEnd().getTime()); } result = Range.combine(result, temp); } } return result; }
From source file:org.jfree.data.time.TimeTableXYDataset.java
/** * Returns the x-value for a time period. * * @param period the time period.//from w ww . j av a 2 s . c om * * @return The x-value. */ private long getXValue(TimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getStart().getTime(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { long t0 = period.getStart().getTime(); long t1 = period.getEnd().getTime(); result = t0 + (t1 - t0) / 2L; } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getEnd().getTime(); } return result; }