Listening for zoom reset event in JFreeChart

前端 未结 2 959
礼貌的吻别
礼貌的吻别 2021-01-22 01:18

How can I listen to JFreeChart\'s zoom reset event?

2条回答
  •  春和景丽
    2021-01-22 02:07

    I did it using this:

    ChartPanel DCP=new ChartPanel(DailyChart){
        @Override
        public void restoreAutoBounds(){
            super.restoreAutoDomainBounds();
            super.restoreAutoRangeBounds();
    
            XYPlot plot=(XYPlot)getChart().getPlot();
    
            Calendar Cal=Calendar.getInstance();
            String dayName=Cal.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.SHORT,new Locale("en", "us")).toLowerCase();
            String tmp[]=((String)Configurations.getWeeklyWorkingSchedule().get(dayName).get("start")).split(":");
            Cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(tmp[0]));
            Cal.set(Calendar.MINUTE, Integer.parseInt(tmp[1]));
            Cal.set(Calendar.SECOND, 0);
            long start=Cal.getTimeInMillis();
            tmp=((String)Configurations.getWeeklyWorkingSchedule().get(dayName).get("end")).split(":");
            Cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(tmp[0]));
            Cal.set(Calendar.MINUTE, Integer.parseInt(tmp[1]));
            Cal.set(Calendar.SECOND, 0);
            long end=Cal.getTimeInMillis();
    
            plot.getDomainAxis().setAutoRange(false);
            plot.getDomainAxis().setRange(start,end);
        }
    };
    DCP.restoreAutoBounds();
    

    Thank You all.

提交回复
热议问题