public void run() {
Object selectedItem = myComboMediaSize
.getSelectedItem();
if (selectedItem != null) {
myMediaSizeName = (MediaSizeName) selectedItem;
MediaSize ms = MediaSize
.getMediaSizeForName(myMediaSizeName);
Paper p = new Paper();
float[] size = ms.getSize(MediaSize.INCH);
p.setSize(size[0] * 72, size[1] * 72);
p.setImageableArea(72, 72,
p.getWidth() - 72 * 2,
p.getHeight() - 72 * 2);
myPageFormat.setPaper(p);
changePageOrientation(myOrientation);
statusBar.setText1(ms.getX(MediaSize.MM)
+ " x " + ms.getY(MediaSize.MM));
myPreviewContainer.repaint();
}
}
});
}
});
}
bPrint.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("printProject"))));
bPortrait.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("portrait"))));
bLandscape.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("landscape"))));
bClose.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("close"))));
final JButton bZoomOut;
final JButton bZoomIn;
if (isDate) {
myWholeProjectButton.setToolTipText(GanttProject
.getToolTip(GanttProject.correctLabel(language
.getText("displayWholeProject"))));
/*
myStartDateButton.setToolTipText(GanttProject
.getToolTip(GanttProject.correctLabel(language
.getText("setStartDate"))));
myEndDateButton.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("setEndDate"))));
*/
//GanttProject gp = Mediator.getGanttProjectSingleton();
final ZoomManager zoomManager = myUIfacade.getZoomManager();
final Action zoomOut = new ZoomOutAction(zoomManager, "16");
final Action zoomIn = new ZoomInAction(zoomManager, "16");
bZoomOut = new JButton((Icon) zoomOut.getValue(Action.SMALL_ICON));
bZoomIn = new JButton((Icon) zoomIn.getValue(Action.SMALL_ICON));
bZoomOut.setHorizontalTextPosition(SwingConstants.RIGHT);
bZoomOut.setText(language.getText("narrowChart"));
bZoomOut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
run(new Runnable() {
public void run() {
zoomOut.actionPerformed(null);
updateSourceImage();
bZoomOut.setEnabled(zoomManager.canZoomOut());
bZoomIn.setEnabled(zoomManager.canZoomIn());
}
});
}
});
bZoomIn.setHorizontalTextPosition(SwingConstants.RIGHT);
bZoomIn.setText(language.getText("widenChart"));
bZoomIn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
run(new Runnable() {
public void run() {
zoomIn.actionPerformed(null);
updateSourceImage();
bZoomOut.setEnabled(zoomManager.canZoomOut());
bZoomIn.setEnabled(zoomManager.canZoomIn());
}
});
}
});
} else {
bZoomOut = null;
bZoomIn = null;
}
tb2.setFloatable(false);
tb.setFloatable(false);
tb.add(bClose);
tb.addSeparator(new Dimension(16, 16));
tb.add(bPrint);
tb.addSeparator(new Dimension(16, 16));
tb.add(bPortrait);
tb.add(bLandscape);
tb.addSeparator(new Dimension(16, 16));
tb.add(new JLabel(language.getText("zoom") + " "));
tb.add(myComboScale);
if (vMedia != null && !vMedia.isEmpty()) {
tb.addSeparator(new Dimension(16, 16));
tb.add(new JLabel(language.getText("choosePaperFormat") + " "));
tb.addSeparator(new Dimension(0, 10));
tb.add(myComboMediaSize);
}
if (isDate) {
tb2.add(bZoomOut);
tb2.addSeparator(new Dimension(5, 0));
tb2.add(bZoomIn);
tb2.addSeparator(new Dimension(20, 0));
tb2.add(myWholeProjectButton);
tb2.addSeparator(new Dimension(16, 16));
OptionsPageBuilder builder = new OptionsPageBuilder();
builder.setOptionKeyPrefix("");
tb2.add(builder.createStandaloneOptionPanel(myStart));
URL iconArrow = this.getClass().getClassLoader().getResource(
"icons/fromto.gif");
tb2.add(new JLabel(new ImageIcon(iconArrow)));
tb2.add(builder.createStandaloneOptionPanel(myFinish));
}
JPanel topPanel = new JPanel(new BorderLayout());
tb.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
tb2.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
topPanel.add(tb, BorderLayout.NORTH);
topPanel.add(tb2, BorderLayout.SOUTH);
getContentPane().add(topPanel, BorderLayout.NORTH);
statusBar = new StatusBar();
statusBar.setLabel0(language.getText("pageNumber"));
statusBar.setLabel1(language.getText("paperSize"));
getContentPane().add(statusBar, BorderLayout.SOUTH);
myPreviewContainer = new PreviewContainer();
PrinterJob prnJob = PrinterJob.getPrinterJob();
// --
myPageFormat = new PageFormat();
myPageFormat.setOrientation(myOrientation);
myMediaSizeName = DEFAULT_MEDIA_SIZE_NAME;
MediaSize ms = MediaSize.getMediaSizeForName(myMediaSizeName);
Paper p = new Paper();
float[] size = ms.getSize(MediaSize.INCH);
p.setSize(size[0] * 72, size[1] * 72);
p.setImageableArea(72, 72, p.getWidth() - 72 * 2,
p.getHeight() - 72 * 2);
myPageFormat.setPaper(p);
// --
statusBar.setText1(ms.getX(MediaSize.MM) + " x "
+ ms.getY(MediaSize.MM));
if (myPageFormat.getHeight() == 0 || myPageFormat.getWidth() == 0) {
myUIfacade.showErrorDialog("Unable to determine default page size");
return;
}