add(editor.bind("Redo", new HistoryAction(false),
"/com/mxgraph/examples/swing/images/redo.gif"));
addSeparator();
final mxGraphView view = editor.getGraphComponent().getGraph()
.getView();
final JComboBox zoomCombo = new JComboBox(new Object[] { "400%",
"200%", "150%", "100%", "75%", "50%", mxResources.get("page"),
mxResources.get("width"), mxResources.get("actualSize") });
zoomCombo.setEditable(true);
zoomCombo.setMinimumSize(new Dimension(75, 0));
zoomCombo.setPreferredSize(new Dimension(75, 0));
zoomCombo.setMaximumSize(new Dimension(75, 100));
zoomCombo.setMaximumRowCount(9);
add(zoomCombo);
// Sets the zoom in the zoom combo the current value
mxIEventListener scaleTracker = new mxIEventListener()
{
/**
*
*/
public void invoke(Object sender, mxEventObject evt)
{
ignoreZoomChange = true;
try
{
zoomCombo.setSelectedItem((int) Math.round(100 * view
.getScale())
+ "%");
}
finally
{
ignoreZoomChange = false;
}
}
};
// Installs the scale tracker to update the value in the combo box
// if the zoom is changed from outside the combo box
view.getGraph().getView().addListener(mxEvent.SCALE, scaleTracker);
view.getGraph().getView().addListener(mxEvent.SCALE_AND_TRANSLATE,
scaleTracker);
// Invokes once to sync with the actual zoom value
scaleTracker.invoke(null, null);