Source Code Cross Referenced for PageDefinitionChooser.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » properties » editors » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.pentaho.reportdesigner.crm.report.properties.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.crm.report.properties.editors;
015:
016:        import com.jgoodies.forms.layout.CellConstraints;
017:        import com.jgoodies.forms.layout.FormLayout;
018:        import org.jetbrains.annotations.NonNls;
019:        import org.jetbrains.annotations.NotNull;
020:        import org.jetbrains.annotations.Nullable;
021:        import org.pentaho.reportdesigner.crm.report.ReportDialog;
022:        import org.pentaho.reportdesigner.crm.report.model.PageDefinition;
023:        import org.pentaho.reportdesigner.crm.report.model.PageFormatPreset;
024:        import org.pentaho.reportdesigner.crm.report.model.PageOrientation;
025:        import org.pentaho.reportdesigner.lib.client.components.CenterPanelDialog;
026:        import org.pentaho.reportdesigner.lib.client.components.ComponentFactory;
027:        import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
028:        import org.pentaho.reportdesigner.lib.client.util.FontUtils;
029:        import org.pentaho.reportdesigner.lib.client.util.WindowUtils;
030:
031:        import javax.swing.*;
032:        import javax.swing.event.DocumentEvent;
033:        import javax.swing.event.DocumentListener;
034:        import java.awt.*;
035:        import java.awt.event.ActionEvent;
036:        import java.awt.event.ActionListener;
037:        import java.awt.geom.Rectangle2D;
038:        import java.text.DecimalFormat;
039:        import java.text.ParseException;
040:        import java.util.logging.Level;
041:        import java.util.logging.Logger;
042:
043:        /**
044:         * User: Martin
045:         * Date: 08.02.2006
046:         * Time: 13:48:23
047:         */
048:        public class PageDefinitionChooser {
049:            @NonNls
050:            @NotNull
051:            private static final Logger LOG = Logger
052:                    .getLogger(PageDefinitionChooser.class.getName());
053:
054:            @NotNull
055:            private static final DecimalFormat decimalFormat = new DecimalFormat(
056:                    "0.0###");
057:
058:            private PageDefinitionChooser() {
059:            }
060:
061:            @NotNull
062:            public static PageDefinition showPageDefinitionChooser(@NotNull
063:            final ReportDialog reportDialog, @NotNull
064:            JComponent parent, @NotNull
065:            String title, @NotNull
066:            PageDefinition pageDefinition) {
067:                final CenterPanelDialog centerPanelDialog = CenterPanelDialog
068:                        .createDialog(parent, title,
069:                                CenterPanelDialog.ModalityType.DOCUMENT_MODAL);
070:
071:                @NonNls
072:                FormLayout formLayout = new FormLayout(
073:                        "0dlu:grow, default, 10dlu, default, 4dlu, max(40dlu;default), 4dlu, default, 4dlu, max(40dlu;default), 0dlu:grow",
074:                        "0dlu, " + "fill:10dlu:grow, " + "4dlu, " + "default, "
075:                                + "4dlu, " + "default, " + "10dlu, "
076:                                + "default, " + "4dlu, " + "default, " + "0dlu");
077:
078:                JPanel centerPanel = new JPanel(formLayout);
079:                @NonNls
080:                CellConstraints cc = new CellConstraints();
081:
082:                final PagePanel pagePanel = new PagePanel(pageDefinition);
083:                centerPanel.add(pagePanel, cc.xyw(1, 2, 11));
084:
085:                final JComboBox paperComboBox = new JComboBox(PageFormatPreset
086:                        .values());
087:                centerPanel.add(paperComboBox, cc.xyw(2, 4, 9));
088:
089:                centerPanel.add(new JLabel(TranslationManager.getInstance()
090:                        .getTranslation(
091:                                "R",
092:                                "PageDefinitionChooser.Width",
093:                                Integer.valueOf(reportDialog
094:                                        .getApplicationSettings().getUnit()
095:                                        .ordinal()))), cc.xy(4, 6));
096:                final JTextField widthTextField = ComponentFactory
097:                        .createTextField(true, true);
098:                centerPanel.add(widthTextField, cc.xy(6, 6));
099:
100:                centerPanel.add(new JLabel(TranslationManager.getInstance()
101:                        .getTranslation(
102:                                "R",
103:                                "PageDefinitionChooser.Height",
104:                                Integer.valueOf(reportDialog
105:                                        .getApplicationSettings().getUnit()
106:                                        .ordinal()))), cc.xy(8, 6));
107:                final JTextField heightTextField = ComponentFactory
108:                        .createTextField(true, true);
109:                centerPanel.add(heightTextField, cc.xy(10, 6));
110:
111:                final JRadioButton portraitRadioButton = new JRadioButton(
112:                        TranslationManager.getInstance().getTranslation("R",
113:                                "PageDefinitionChooser.Portrait"));
114:                centerPanel.add(portraitRadioButton, cc.xy(2, 8));
115:
116:                centerPanel.add(new JLabel(TranslationManager.getInstance()
117:                        .getTranslation(
118:                                "R",
119:                                "PageDefinitionChooser.Top",
120:                                Integer.valueOf(reportDialog
121:                                        .getApplicationSettings().getUnit()
122:                                        .ordinal()))), cc.xy(4, 8));
123:                final JTextField topTextField = ComponentFactory
124:                        .createTextField(true, true);
125:                centerPanel.add(topTextField, cc.xy(6, 8));
126:
127:                centerPanel.add(new JLabel(TranslationManager.getInstance()
128:                        .getTranslation(
129:                                "R",
130:                                "PageDefinitionChooser.Bottom",
131:                                Integer.valueOf(reportDialog
132:                                        .getApplicationSettings().getUnit()
133:                                        .ordinal()))), cc.xy(8, 8));
134:                final JTextField bottomTextField = ComponentFactory
135:                        .createTextField(true, true);
136:                centerPanel.add(bottomTextField, cc.xy(10, 8));
137:
138:                final JRadioButton landscapeRadioButton = new JRadioButton(
139:                        TranslationManager.getInstance().getTranslation("R",
140:                                "PageDefinitionChooser.Landscape"));
141:                centerPanel.add(landscapeRadioButton, cc.xy(2, 10));
142:
143:                centerPanel.add(new JLabel(TranslationManager.getInstance()
144:                        .getTranslation(
145:                                "R",
146:                                "PageDefinitionChooser.Left",
147:                                Integer.valueOf(reportDialog
148:                                        .getApplicationSettings().getUnit()
149:                                        .ordinal()))), cc.xy(4, 10));
150:                final JTextField leftTextField = ComponentFactory
151:                        .createTextField(true, true);
152:                centerPanel.add(leftTextField, cc.xy(6, 10));
153:
154:                centerPanel.add(new JLabel(TranslationManager.getInstance()
155:                        .getTranslation(
156:                                "R",
157:                                "PageDefinitionChooser.Right",
158:                                Integer.valueOf(reportDialog
159:                                        .getApplicationSettings().getUnit()
160:                                        .ordinal()))), cc.xy(8, 10));
161:                final JTextField rigthTextField = ComponentFactory
162:                        .createTextField(true, true);
163:                centerPanel.add(rigthTextField, cc.xy(10, 10));
164:
165:                ButtonGroup buttonGroup = new ButtonGroup();
166:                buttonGroup.add(portraitRadioButton);
167:                buttonGroup.add(landscapeRadioButton);
168:
169:                PageFormatPreset preset = PageFormatPreset
170:                        .getPreset(pageDefinition);
171:
172:                paperComboBox.setSelectedItem(preset);
173:
174:                if (pageDefinition.getPageOrientation() == PageOrientation.LANDSCAPE) {
175:                    landscapeRadioButton.setSelected(true);
176:                } else {
177:                    portraitRadioButton.setSelected(true);
178:                }
179:
180:                widthTextField.setText(decimalFormat.format(reportDialog
181:                        .getApplicationSettings().getUnit().convertFromPoints(
182:                                pageDefinition.getOuterPageSize().getWidth())));
183:                heightTextField
184:                        .setText(decimalFormat.format(reportDialog
185:                                .getApplicationSettings().getUnit()
186:                                .convertFromPoints(
187:                                        pageDefinition.getOuterPageSize()
188:                                                .getHeight())));
189:
190:                widthTextField.setEditable(preset == PageFormatPreset.CUSTOM);
191:                heightTextField.setEditable(preset == PageFormatPreset.CUSTOM);
192:
193:                topTextField.setText(decimalFormat.format(reportDialog
194:                        .getApplicationSettings().getUnit().convertFromPoints(
195:                                pageDefinition.getTopBorder())));
196:                bottomTextField.setText(decimalFormat.format(reportDialog
197:                        .getApplicationSettings().getUnit().convertFromPoints(
198:                                pageDefinition.getBottomBorder())));
199:                leftTextField.setText(decimalFormat.format(reportDialog
200:                        .getApplicationSettings().getUnit().convertFromPoints(
201:                                pageDefinition.getLeftBorder())));
202:                rigthTextField.setText(decimalFormat.format(reportDialog
203:                        .getApplicationSettings().getUnit().convertFromPoints(
204:                                pageDefinition.getRightBorder())));
205:
206:                ActionListener al = new ActionListener() {
207:                    public void actionPerformed(@NotNull
208:                    ActionEvent e) {
209:                        PageFormatPreset preset = (PageFormatPreset) paperComboBox
210:                                .getSelectedItem();
211:                        widthTextField
212:                                .setEditable(preset == PageFormatPreset.CUSTOM);
213:                        heightTextField
214:                                .setEditable(preset == PageFormatPreset.CUSTOM);
215:
216:                        PageDefinition pageDefinition = buildPageDefinition(
217:                                reportDialog, paperComboBox,
218:                                portraitRadioButton, widthTextField,
219:                                heightTextField, topTextField, bottomTextField,
220:                                leftTextField, rigthTextField);
221:                        if (pageDefinition != null) {
222:                            pagePanel.setPageDefinition(pageDefinition);
223:
224:                            widthTextField.setText(decimalFormat
225:                                    .format(reportDialog
226:                                            .getApplicationSettings().getUnit()
227:                                            .convertFromPoints(
228:                                                    pageDefinition
229:                                                            .getOuterPageSize()
230:                                                            .getWidth())));
231:                            heightTextField.setText(decimalFormat
232:                                    .format(reportDialog
233:                                            .getApplicationSettings().getUnit()
234:                                            .convertFromPoints(
235:                                                    pageDefinition
236:                                                            .getOuterPageSize()
237:                                                            .getHeight())));
238:                        }
239:                    }
240:                };
241:                portraitRadioButton.addActionListener(al);
242:                landscapeRadioButton.addActionListener(al);
243:                paperComboBox.addActionListener(al);
244:
245:                DocumentListener dl = new DocumentListener() {
246:                    public void insertUpdate(@NotNull
247:                    DocumentEvent e) {
248:                        PageDefinition pageDefinition = buildPageDefinition(
249:                                reportDialog, paperComboBox,
250:                                portraitRadioButton, widthTextField,
251:                                heightTextField, topTextField, bottomTextField,
252:                                leftTextField, rigthTextField);
253:                        pagePanel.setPageDefinition(pageDefinition);
254:                    }
255:
256:                    public void removeUpdate(@NotNull
257:                    DocumentEvent e) {
258:                        PageDefinition pageDefinition = buildPageDefinition(
259:                                reportDialog, paperComboBox,
260:                                portraitRadioButton, widthTextField,
261:                                heightTextField, topTextField, bottomTextField,
262:                                leftTextField, rigthTextField);
263:                        pagePanel.setPageDefinition(pageDefinition);
264:                    }
265:
266:                    public void changedUpdate(@NotNull
267:                    DocumentEvent e) {
268:                        PageDefinition pageDefinition = buildPageDefinition(
269:                                reportDialog, paperComboBox,
270:                                portraitRadioButton, widthTextField,
271:                                heightTextField, topTextField, bottomTextField,
272:                                leftTextField, rigthTextField);
273:                        pagePanel.setPageDefinition(pageDefinition);
274:                    }
275:                };
276:                widthTextField.getDocument().addDocumentListener(dl);
277:                heightTextField.getDocument().addDocumentListener(dl);
278:                topTextField.getDocument().addDocumentListener(dl);
279:                bottomTextField.getDocument().addDocumentListener(dl);
280:                leftTextField.getDocument().addDocumentListener(dl);
281:                rigthTextField.getDocument().addDocumentListener(dl);
282:
283:                final boolean[] action = new boolean[] { false };
284:
285:                JButton okButton = new JButton(TranslationManager.getInstance()
286:                        .getTranslation("R", "Button.ok"));
287:                okButton.addActionListener(new ActionListener() {
288:                    public void actionPerformed(@NotNull
289:                    ActionEvent e) {
290:                        action[0] = true;
291:                        centerPanelDialog.dispose();
292:                    }
293:                });
294:
295:                JButton cancelButton = new JButton(TranslationManager
296:                        .getInstance().getTranslation("R", "Button.cancel"));
297:                cancelButton.addActionListener(new ActionListener() {
298:                    public void actionPerformed(@NotNull
299:                    ActionEvent e) {
300:                        action[0] = false;
301:                        centerPanelDialog.dispose();
302:                    }
303:                });
304:
305:                centerPanelDialog.setButtons(okButton, cancelButton, okButton,
306:                        cancelButton);
307:
308:                centerPanelDialog.setCenterPanel(centerPanel);
309:                centerPanelDialog.setSize(500, 500);
310:                WindowUtils.setLocationRelativeTo(centerPanelDialog, parent);
311:                centerPanelDialog.setVisible(true);
312:
313:                if (action[0]) {
314:                    return pagePanel.getPageDefinition();
315:                }
316:                return pageDefinition;
317:            }
318:
319:            @Nullable
320:            private static PageDefinition buildPageDefinition(@NotNull
321:            ReportDialog reportDialog, @NotNull
322:            JComboBox paperComboBox, @NotNull
323:            JRadioButton portraitRadioButton, @NotNull
324:            JTextField widthTextField, @NotNull
325:            JTextField heightTextField, @NotNull
326:            JTextField topTextField, @NotNull
327:            JTextField bottomTextField, @NotNull
328:            JTextField leftTextField, @NotNull
329:            JTextField rightTextField) {
330:                PageFormatPreset pageFormatPreset;
331:                double width;
332:                double height;
333:                double topBorder;
334:                double bottomBorder;
335:                double leftBorder;
336:                double rightBorder;
337:                PageOrientation pageOrientation;
338:                try {
339:                    pageFormatPreset = (PageFormatPreset) paperComboBox
340:                            .getSelectedItem();
341:                    width = reportDialog.getApplicationSettings().getUnit()
342:                            .convertToPoints(
343:                                    decimalFormat.parse(
344:                                            widthTextField.getText())
345:                                            .doubleValue());
346:                    height = reportDialog.getApplicationSettings().getUnit()
347:                            .convertToPoints(
348:                                    decimalFormat.parse(
349:                                            heightTextField.getText())
350:                                            .doubleValue());
351:                    topBorder = reportDialog.getApplicationSettings().getUnit()
352:                            .convertToPoints(
353:                                    decimalFormat.parse(topTextField.getText())
354:                                            .doubleValue());
355:                    bottomBorder = reportDialog.getApplicationSettings()
356:                            .getUnit().convertToPoints(
357:                                    decimalFormat.parse(
358:                                            bottomTextField.getText())
359:                                            .doubleValue());
360:                    leftBorder = reportDialog.getApplicationSettings()
361:                            .getUnit().convertToPoints(
362:                                    decimalFormat
363:                                            .parse(leftTextField.getText())
364:                                            .doubleValue());
365:                    rightBorder = reportDialog.getApplicationSettings()
366:                            .getUnit().convertToPoints(
367:                                    decimalFormat.parse(
368:                                            rightTextField.getText())
369:                                            .doubleValue());
370:                    pageOrientation = portraitRadioButton.isSelected() ? PageOrientation.PORTRAIT
371:                            : PageOrientation.LANDSCAPE;
372:                } catch (NumberFormatException e) {
373:                    //ok
374:                    if (LOG.isLoggable(Level.FINE))
375:                        LOG
376:                                .log(
377:                                        Level.FINE,
378:                                        "PageDefinitionChooser.buildPageDefinition ",
379:                                        e);
380:                    return null;
381:                } catch (ParseException e) {
382:                    //ok
383:                    if (LOG.isLoggable(Level.FINE))
384:                        LOG
385:                                .log(
386:                                        Level.FINE,
387:                                        "PageDefinitionChooser.buildPageDefinition ",
388:                                        e);
389:                    return null;
390:                }
391:
392:                if (topBorder < 0 || bottomBorder < 0 || leftBorder < 0
393:                        || rightBorder < 0) {
394:                    return null;
395:                }
396:
397:                PageDefinition pageDefinition;
398:                if (pageFormatPreset == PageFormatPreset.CUSTOM) {
399:                    pageDefinition = new PageDefinition(pageFormatPreset,
400:                            pageOrientation, topBorder, bottomBorder,
401:                            leftBorder, rightBorder, width, height);
402:                } else {
403:                    pageDefinition = new PageDefinition(pageFormatPreset,
404:                            pageOrientation, topBorder, bottomBorder,
405:                            leftBorder, rightBorder);
406:                }
407:
408:                if (pageDefinition.getInnerPageSize().getWidth() <= 0) {
409:                    return null;
410:                } else if (pageDefinition.getInnerPageSize().getHeight() <= 0) {
411:                    return null;
412:                }
413:                return pageDefinition;
414:            }
415:
416:            private static class PagePanel extends JPanel {
417:
418:                @NotNull
419:                private PageDefinition pageDefinition;
420:                private boolean error;
421:
422:                @NotNull
423:                private Font bigFont;
424:
425:                private PagePanel(@NotNull
426:                PageDefinition pageDefinition) {
427:                    this .pageDefinition = pageDefinition;
428:
429:                    bigFont = FontUtils
430:                            .getDerivedFont(getFont(), Font.BOLD, 24);
431:                }
432:
433:                @NotNull
434:                public PageDefinition getPageDefinition() {
435:                    return pageDefinition;
436:                }
437:
438:                public boolean isError() {
439:                    return error;
440:                }
441:
442:                public void setPageDefinition(@Nullable
443:                PageDefinition pageDefinition) {
444:                    if (pageDefinition == null) {
445:                        error = true;
446:                    } else {
447:                        this .pageDefinition = pageDefinition;
448:                        error = false;
449:                    }
450:                    repaint();
451:                }
452:
453:                protected void paintComponent(@NotNull
454:                Graphics g) {
455:                    super .paintComponent(g);
456:
457:                    double wf = (getWidth() - 10)
458:                            / (pageDefinition.getInnerPageSize().getWidth()
459:                                    + pageDefinition.getLeftBorder() + pageDefinition
460:                                    .getRightBorder());
461:                    double hf = (getHeight() - 10)
462:                            / (pageDefinition.getInnerPageSize().getHeight()
463:                                    + pageDefinition.getTopBorder() + pageDefinition
464:                                    .getBottomBorder());
465:
466:                    double scaleFactor;
467:                    if (wf > hf) {
468:                        scaleFactor = hf;
469:                    } else {
470:                        scaleFactor = wf;
471:                    }
472:
473:                    double w = getWidth();
474:                    double h = getHeight();
475:
476:                    g.setColor(new Color(240, 240, 240));
477:                    double ow = (pageDefinition.getInnerPageSize().getWidth()
478:                            + pageDefinition.getLeftBorder() + pageDefinition
479:                            .getRightBorder())
480:                            * scaleFactor;
481:                    double oh = (pageDefinition.getInnerPageSize().getHeight()
482:                            + pageDefinition.getTopBorder() + pageDefinition
483:                            .getBottomBorder())
484:                            * scaleFactor;
485:
486:                    int xStart = (int) (w - ow) / 2;
487:                    int yStart = (int) (h - oh) / 2;
488:
489:                    g.fillRect(xStart, yStart, (int) ow, (int) oh);
490:                    g.setColor(Color.LIGHT_GRAY);
491:                    g.drawRect(xStart, yStart, (int) ow, (int) oh);
492:
493:                    double iw = (pageDefinition.getInnerPageSize().getWidth())
494:                            * scaleFactor;
495:                    double ih = (pageDefinition.getInnerPageSize().getHeight())
496:                            * scaleFactor;
497:                    g.setColor(Color.WHITE);
498:                    g
499:                            .fillRect(
500:                                    xStart
501:                                            + (int) (pageDefinition
502:                                                    .getLeftBorder() * scaleFactor),
503:                                    yStart
504:                                            + (int) (pageDefinition
505:                                                    .getTopBorder() * scaleFactor),
506:                                    (int) iw, (int) ih);
507:                    g.setColor(Color.LIGHT_GRAY);
508:                    g
509:                            .drawRect(
510:                                    xStart
511:                                            + (int) (pageDefinition
512:                                                    .getLeftBorder() * scaleFactor),
513:                                    yStart
514:                                            + (int) (pageDefinition
515:                                                    .getTopBorder() * scaleFactor),
516:                                    (int) iw, (int) ih);
517:
518:                    PageFormatPreset preset = PageFormatPreset
519:                            .getPreset(pageDefinition);
520:                    Font origFont = g.getFont();
521:                    g.setFont(bigFont);
522:                    Graphics2D g2d = (Graphics2D) g;
523:                    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
524:                            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
525:                    Rectangle2D stringBounds = g.getFontMetrics()
526:                            .getStringBounds(preset.toString(), g);
527:                    g
528:                            .drawString(preset.toString(),
529:                                    (int) ((getWidth() - stringBounds
530:                                            .getWidth()) / 2),
531:                                    (int) ((getHeight() - stringBounds
532:                                            .getHeight()) / 2 - stringBounds
533:                                            .getY()));
534:                    g.setFont(origFont);
535:
536:                    if (error) {
537:                        g.setColor(Color.RED);
538:                        g.drawString(TranslationManager.getInstance()
539:                                .getTranslation("R",
540:                                        "PagePanel.InvalidPageDefinition"),
541:                                xStart + 20, yStart + 20);
542:                    }
543:                }
544:            }
545:        }
w___w_w___.j__a___v__a___2___s__._co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.