Page 1 of 1

strange!!!

Posted: Mon Nov 05, 2007 4:27 am
by Tony Young
I've seen the codes in pakage "FC guide",
I wrote a program similar with the CandlestickChartDemo1.java
here is my program:

Code: Select all

public class temptest extends ApplicationFrame
{

    public temptest(String s)
    {
        super(s);
        OHLCDataset ohlcdataset = createDataset();
        JFreeChart jfreechart = createChart(ohlcdataset);
        jfreechart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
        ChartPanel chartpanel = new ChartPanel(jfreechart);
        chartpanel.setPreferredSize(new Dimension(500, 500));
        setContentPane(chartpanel);
    }

    private static JFreeChart createChart(OHLCDataset ohlcdataset)
    {
        JFreeChart jfreechart = ChartFactory.createCandlestickChart("Candlestick Demo", "Time", "Value", ohlcdataset, true);
        return jfreechart;
    }

    public static OHLCDataset createDataset()
    { ......//data........}

    public static JPanel createDemoPanel()
    {
        JFreeChart jfreechart = createChart(createDataset());
        return new ChartPanel(jfreechart);
    }

    public static void main(String args[])
    {
       temptest mytest= new temptest("mytest");
        candlestickchartdemo1.pack();
        RefineryUtilities.centerFrameOnScreen(mytest);
        mytest.setVisible(true);
    }
}
:?: :?: :?:
I've found nothing about dealing with mouse event...but it was performed well.
How can it be?!

Posted: Mon Nov 05, 2007 7:14 am
by jwenting
small gnomes eating magic brownies that sit in your computer reading the JFreeChart sourcecode :shock:

Posted: Mon Nov 05, 2007 8:21 am
by Tony Young
Hi:jwenting
sorry....what's your meaning :shock: :shock: :shock: :shock:

Posted: Mon Nov 05, 2007 12:39 pm
by jwenting
it happens automagically.

Posted: Mon Nov 05, 2007 12:48 pm
by Taqua
.. or in other words: It happens in the ChartPanel class. You would have found it out by yourself quite easily if you would either look at the sourcecode *or* the JavaDocs for that class.

Use the source, Luke! Or at least read the documentation. If you believe in magic or hope that code snippets found in the Internet save you, you will only harm yourself. Using a tool wit just the firm believe in magic, you will end up shooting yourself in the foot with a magic wand.

Posted: Mon Nov 05, 2007 3:34 pm
by jwenting
I like he magic brownies better 8)

Posted: Tue Nov 06, 2007 2:44 am
by Tony Young
Hi:
In default way, it zoomed in(out) when I dragged the mouse
But in my program, I want to use mouse wheel to zoom in or zoom out .
So I decide to write the method by myself, but I can't get any help from the source code, will someone explain me how to do this??