Here is a source code that implement a simple solution.
Here is a source code that implement a simple solution. Import java.awt. BorderLayout; import java.util.
Date; import javax.swing. BorderFactory; import javax.swing. JPanel; import javax.swing.
JSlider; import javax.swing.border. Border; import javax.swing.event. ChangeEvent; import javax.swing.event.
ChangeListener; import org.jfree.chart. ChartPanel; import org.jfree.chart. JFreeChart; import org.jfree.chart.axis.
DateAxis; import org.jfree.chart.axis. NumberAxis; import org.jfree.chart.plot. XYPlot; import org.jfree.chart.renderer.xy.
XYBarRenderer; import org.jfree.data.time. DateRange; import org.jfree.data.time. Day; import org.jfree.data.time.
RegularTimePeriod; import org.jfree.data.time. TimeSeries; import org.jfree.data.time. TimeSeriesCollection; import org.jfree.ui.
ApplicationFrame; import org.jfree.ui. RefineryUtilities; public class DomainTranslateDemo extends ApplicationFrame { private static class DemoPanel extends JPanel implements ChangeListener { private static int SLIDER_INITIAL_VALUE = 50; private JSlider slider; private DateAxis domainAxis; private int lastValue = SLIDER_INITIAL_VALUE; // one month (milliseconds, seconds, minutes, hours, days) private int delta = 1000 * 60 * 60 * 24 * 30; public DemoPanel() { super(new BorderLayout()); JFreeChart chart = createChart(); ChartPanel chartPanel = new ChartPanel(chart); chartPanel. SetPreferredSize(new java.awt.
Dimension(600, 270)); chartPanel. SetDomainZoomable(true); chartPanel. SetRangeZoomable(true); Border border = BorderFactory.
CreateCompoundBorder( BorderFactory. CreateEmptyBorder(4, 4, 4, 4), BorderFactory. CreateEtchedBorder() ); chartPanel.
SetBorder(border); add(chartPanel); JPanel dashboard = new JPanel(new BorderLayout()); dashboard. SetBorder(BorderFactory. CreateEmptyBorder(0, 4, 4, 4)); this.
Slider = new JSlider(0, 100, SLIDER_INITIAL_VALUE); this.slider. AddChangeListener(this); dashboard. Add(this.
Slider); add(dashboard, BorderLayout. SOUTH); } private JFreeChart createChart() { TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); TimeSeries series = createSerie(500,20); timeSeriesCollection. AddSeries(series ); this.
DomainAxis = new DateAxis("Time"); NumberAxis rangeAxis = new NumberAxis(""); XYBarRenderer renderer = new XYBarRenderer(); renderer. SetShadowVisible(false); XYPlot plot = new XYPlot(timeSeriesCollection, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart( "Title", JFreeChart. DEFAULT_TITLE_FONT, plot, true); // performance chart.
SetAntiAlias(false); return chart; } private TimeSeries createSerie(int domainCount,int rangeCount) { TimeSeries timeSeries = new TimeSeries("timeSeries1"); Day d = new Day(new Date()); RegularTimePeriod regularTimePeriod = d.next(); for (int index = 0; index CenterFrameOnScreen(demo); demo. SetVisible(true); } }.
Thanks trashgod :D But I gave up on this approach. I need to get some work done over here ;) So in order to navigate on the graph I used a different dataset org.jfree.data.time. DynamicTimeSeriesCollection.
This class is aimed for real-time applications in which we have the ability to append new data and discard the oldest in a pretty fast way (depend on your input data). In summary, every time that someone scroll the bar I just need to change my underlying dataset, and that will fire a PlotChangeEvent which, in turn, gets passed on to the chart and results in a ChartChangeEvent being fired. This chain of events is used to ensure that charts are automatically updated whenever a change is made to any component of the chart.
Once again, thank you very much.
Seems like a reasonable alternative, and cleaner than the demo; +1. BTW, you need to use the @ tag for anyone but you to see a response. – trashgod Jul 15 '10 at 1:48 @trashgod: I found a new alternative, see you.
– Max Jul 16 '10 at 22:55.
TranslatingXYDataset presently implements XYDataset; instead, you'll need to implement IntervalXYDataset, as required by JFreeChart. CreateXYBarChart.
Yep, you are right. BUT still not working :(. When I implement the IntervalXYDataset instead of XYDataset I have to code some other methods such as: @Override public double getStartXValue(int series, int item) { return underlying.
GetStartXValue(series, item); } @Override public double getEndXValue(int series, int item) { return underlying. GetEndXValue(series, item); } I am not sure what extra modifications should I do on body of those methods. – Max Jul 13 '10 at 2:12 @Max: It looks like the default renderer for JFreeChart.
CreateXYBarChart, XYBarRenderer, is not happy. Does setShadowVisible(false) help? – trashgod Jul 13 '10 at 3:09.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.