Resizing Graphics
The Viewable class supports resizing of the Viewable object in the client without a roundtrip to the server. The default resize behavior is NOT_RESIZEABLE. This means that the Viewable object will always be drawn at its ‘natural’ size (as generated by PV‑WAVE), regardless of the size of the Component it is drawn into.
You may want to use Viewable.setPreferredResizeMode with either RESIZEABLE or PRESERVE_ASPECT if your Component is resizable. These modes allow the Viewable object to draw a scaled version of the plot into any size Component. The PRESERVE_ASPECT will resize the Viewable object, but only as much as is possible while maintaining the original (as generated by PV‑WAVE) aspect ratio of the Viewable object.
Resizable is a client-side resizing of a bitmap. It is also possible to resize by making a new request to the server. In the example, SimpleView.java, the SimpleView constructor can be modified to listen for resize events generated by the frame and request a new chart at the new size.
Following is the modified constructor. Note that this relies on the fact that Chart.update() resets the view size to the current size of the canvas.
public SimpleView() throws JWaveException {
MainFrame mainFrame = new MainFrame();
// Add a chart to the frame
final Chart chart = new Chart();
mainFrame.add(chart);
// Make the frame visible and draw the chart
mainFrame.setVisible(true);
mainFrame.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent event) {
try {
chart.update();
} catch (JWaveException e) {
System.out.println(e);
}
}
});
chart.update();
}
Version 3.6
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.