I have the following method
private void passStingR(StringBuilder retVal) throws BadLocationException, Exception {
int getinitialscrollpos;
getinitialscrollpos = getinitialscrollPosition(scrollMEL);
//1. get chartPanel Bounds
Rectangle2D xy = chartPanel.getScreenDataArea();
Rectangle bounds = chartPanel.getBounds();
int horz = (int) bounds.getX();//need to get the correct x and y
int vertz = (int) bounds.getY();
int width1 = (int) bounds.getWidth();
int height1 = (int) bounds.getHeight();
System.out.println(horz + " " + vertz + " " + width1 + " " +height1);//get positioning data
/////////////////////////////////
Document docR = null;
docR = loadXMLFromString(retVal.toString());//pull in the XML data into a new doc
populate1R(docR);
tableMEL.getTableHeader().setReorderingAllowed(false);//prevent user from changing column order now at refresh level
SimpleDateFormat time_formatterR = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String current_time_strR = time_formatterR.format(System.currentTimeMillis());
updatetFieldDG.setText(current_time_strR);
middlePanel.add(scrollMEL);
scrollMEL.getVerticalScrollBar().setValue(getinitialscrollpos);
System.out.println("End" + getinitialscrollpos);
getTableData(tableMEL);
head(tableMEL);
createGraphGUI();
//2.the problem lies here as i would expect the chartPanel.setBounds to restore the position that i got at 1.
chartPanel.setBounds(horz,vertz,width1,height1);//xywidthheight
System.out.println(chartPanel.getBounds());//set the positioning items as per the start
////////////
}
The issue is that when my data is refreshed i lose the zoom positioning.
I have therefore tried to get the chartPanel bounds at the start of the method and then try to apply it at the end of the method - however the zoom positioning just keeps on reverting back to the default position which is just the whole graph. Please can someone help?