NbDocument.Colors
moved to org.openide.options.
+ Class NbDocument.Colors
was removed to remove dependency on org.openide.options.
+ Runtime backward compatibility was ensured by moving into org.openide.options module which is
+ already deprecated.
+
NbDocument.COLORS
+ Field NbDocument.COLORS
was removed to remove dependency on org.openide.options.
+
PrintPreferences
+ Class PrintPreferences
was added as replacement for original
+ class PrintSettings
.
+
PrintSettings
+ Classes PrintSettings
and PrintSettingsBeanInfo
+ were removed. Runtime backward compatibility was ensured
+ by moving both into org.openide.options module which is already deprecated.
+
PageFormat
that describes the size and
+ * orientation of a page to be printed.
+ */
+ public static PageFormat getPageFormat(PrinterJob pj) {
+ PageFormat pageFormat = null;
+ pageFormat = pj.defaultPage();
+ Paper p = pageFormat.getPaper();
+ int pageOrientation = getPreferences().getInt(PROP_PAGE_ORIENTATION, pageFormat.getOrientation());
+ double paperWidth = getPreferences().getDouble(PROP_PAGE_WIDTH, p.getWidth());
+ double paperHeight = getPreferences().getDouble(PROP_PAGE_HEIGHT, p.getHeight());
+
+ double iaWidth = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, p.getImageableWidth());
+ double iaHeight = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, p.getImageableHeight());
+ double iaX = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_X, p.getImageableX());
+ double iaY = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_Y, p.getImageableY());
+
+ pageFormat.setOrientation(pageOrientation);
+ p.setSize(paperWidth, paperHeight);
+ p.setImageableArea(iaX, iaY, iaWidth, iaHeight);
+ pageFormat.setPaper(p);
+ return pageFormat;
+ }
+
+ /**
+ * @param pf PageFormat
that describes the size and
+ * orientation of a page to be printed
+ */
+ public static void setPageFormat(PageFormat pf) {
+ getPreferences().putInt(PROP_PAGE_ORIENTATION, pf.getOrientation());
+ getPreferences().putDouble(PROP_PAGE_WIDTH, pf.getPaper().getWidth());
+ getPreferences().putDouble(PROP_PAGE_HEIGHT, pf.getPaper().getHeight());
+
+ getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, pf.getPaper().getImageableWidth());
+ getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, pf.getPaper().getImageableHeight());
+ getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_X, pf.getPaper().getImageableX());
+ getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_Y, pf.getPaper().getImageableY());
+ }
+
+ /**
+ * Wrap lines.
+ * @return true if lines that are too long for the page size will be wrapped
+ * to the following line. If false is returned, then long lines will be truncated.
+ */
+ public static boolean getWrap() {
+ return getPreferences().getBoolean(PROP_WRAP, true);
+ }
+
+ /**
+ * @param wrap
+ * See {@link #getWrap}
+ */
+ public static void setWrap(boolean wrap) {
+ if (getWrap() == wrap) return;
+ getPreferences().putBoolean(PROP_WRAP, wrap);
+ }
+
+ /**
+ * See {@link #setHeaderFormat}
+ * @return the text for the page header
+ */
+ public static String getHeaderFormat() {
+ return getPreferences().get(PROP_HEADER_FORMAT,
+ NbBundle.getMessage(PrintPreferences.class, "CTL_Header_format"));
+ }
+
+ /**
+ * Set the text for the page header.
+ * The following special characters can be used:
+ * correction
the amount of vertical space to print between lines.
+ * @exception IllegalArgumentException if correction is less than 0.
+ */
+ public static void setLineAscentCorrection(float correction) {
+ if (getLineAscentCorrection() == correction) return;
+ if (correction < 0) {
+ throw new IllegalArgumentException();
+ }
+ getPreferences().putFloat(PROP_LINE_ASCENT_CORRECTION, correction);
+ }
+}
Index: openide/text/src/org/openide/text/PrintSettings.java
===================================================================
RCS file: openide/text/src/org/openide/text/PrintSettings.java
diff -N openide/text/src/org/openide/text/PrintSettings.java
--- openide/text/src/org/openide/text/PrintSettings.java 23 Nov 2006 05:26:45 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,457 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-package org.openide.text;
-
-import org.openide.options.ContextSystemOption;
-import org.openide.util.HelpCtx;
-import org.openide.util.NbBundle;
-
-import java.awt.Font;
-import java.awt.print.PageFormat;
-import java.awt.print.Paper;
-import java.awt.print.PrinterJob;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/** Settings for output window.
-*
-* @author Ales Novak
-*/
-public final class PrintSettings extends ContextSystemOption {
- // final because overrides Externalizable methods
-
- /** serialVersionUID */
- static final long serialVersionUID = -9102470021814206818L;
-
- /** Constant for center position of page header. */
- public static final int CENTER = 0x1;
-
- /** Constant for right position of page header. */
- public static final int RIGHT = 0x2;
-
- /** Constant for left position of page header. */
- public static final int LEFT = 0x0;
-
- /** Property name of the wrap property */
- public static final String PROP_PAGE_FORMAT = "pageFormat"; // NOI18N
-
- /** Property name of the wrap property */
- public static final String PROP_WRAP = "wrap"; // NOI18N
-
- /** Property name of the header format property */
- public static final String PROP_HEADER_FORMAT = "headerFormat"; // NOI18N
-
- /** Property name of the footer format property */
- public static final String PROP_FOOTER_FORMAT = "footerFormat"; // NOI18N
-
- /** Property name of the header font property */
- public static final String PROP_HEADER_FONT = "headerFont"; // NOI18N
-
- /** Property name of the footer font property */
- public static final String PROP_FOOTER_FONT = "footerFont"; // NOI18N
-
- /** Property name of the header alignment property */
- public static final String PROP_HEADER_ALIGNMENT = "headerAlignment"; // NOI18N
-
- /** Property name of the footer alignment property */
- public static final String PROP_FOOTER_ALIGNMENT = "footerAlignment"; // NOI18N
-
- /** Property name of the line ascent correction property */
- public static final String PROP_LINE_ASCENT_CORRECTION = "lineAscentCorrection"; // NOI18N
- private static final String HELP_ID = "editing.printing"; // !!! NOI18N
-
- /** PageFormat */
- private static PageFormat pageFormat;
-
- /** Wrap lines? */
- private static boolean wrap = true;
-
- /** Header format - see MessageFormat */
- private static String headerFormat;
-
- /** Footer format - see MessageFormat */
- private static String footerFormat;
-
- /** Header font */
- private static Font headerFont;
-
- /** Footer font */
- private static Font footerFont;
-
- /** Header alignment */
- private static int headerAlignment = CENTER;
-
- /** Footer alignment */
- private static int footerAlignment = CENTER;
-
- /** Line ascent correction parameter. Ranged from 0 to infinity.*/
- private static float lineAscentCorrection = 1.0f;
-
- /** Externalizes this SystemOption
- * @param obtos
- * @exception IOException
- */
- public void writeExternal(ObjectOutput obtos) throws IOException {
- super.writeExternal(obtos);
- obtos.writeBoolean(wrap);
- obtos.writeObject(headerFormat);
- obtos.writeObject(footerFormat);
- obtos.writeObject(headerFont);
- obtos.writeObject(footerFont);
- obtos.writeInt(headerAlignment);
- obtos.writeInt(footerAlignment);
- externalizePageFormat(pageFormat, obtos);
- }
-
- /** Deexetrnalizes this SystemOption
- * @param obtis
- * @exception IOException
- * @exception ClassNotFoundException
- */
- public void readExternal(ObjectInput obtis) throws IOException, ClassNotFoundException {
- super.readExternal(obtis);
- wrap = obtis.readBoolean();
- headerFormat = (String) obtis.readObject();
- footerFormat = (String) obtis.readObject();
- headerFont = (Font) obtis.readObject();
- footerFont = (Font) obtis.readObject();
- headerAlignment = obtis.readInt();
- footerAlignment = obtis.readInt();
- pageFormat = internalizePageFormat(obtis);
- }
-
- /** Writes a PageFormat instance into ObjectOutput
- * @param pf
- * @param obtos
- */
- private static void externalizePageFormat(PageFormat pf, ObjectOutput obtos)
- throws IOException {
- if (pf == null) {
- obtos.writeInt(PageFormat.LANDSCAPE ^ PageFormat.REVERSE_LANDSCAPE ^ PageFormat.PORTRAIT);
-
- return;
- }
-
- obtos.writeInt(pf.getOrientation());
-
- Paper paper = pf.getPaper();
-
- // paper size
- obtos.writeDouble(paper.getWidth());
- obtos.writeDouble(paper.getHeight());
-
- // paper imageable area
- obtos.writeDouble(paper.getImageableX());
- obtos.writeDouble(paper.getImageableY());
- obtos.writeDouble(paper.getImageableWidth());
- obtos.writeDouble(paper.getImageableHeight());
- }
-
- /** Reads a PageFormat instance from ObjectInput
- * @param obtis
- * @return deserialized PageFormat instance
- */
- private static PageFormat internalizePageFormat(ObjectInput obtis)
- throws IOException, ClassNotFoundException {
- PageFormat pf = new PageFormat();
- Paper paper = pf.getPaper();
- int etc = obtis.readInt();
-
- if (etc == (PageFormat.LANDSCAPE ^ PageFormat.REVERSE_LANDSCAPE ^ PageFormat.PORTRAIT)) {
- return null;
- }
-
- pf.setOrientation(etc);
-
- // paper size
- paper.setSize(obtis.readDouble(), obtis.readDouble());
-
- // imageable
- paper.setImageableArea(obtis.readDouble(), obtis.readDouble(), obtis.readDouble(), obtis.readDouble());
- pf.setPaper(paper);
-
- return pf;
- }
-
- public String displayName() {
- return NbBundle.getMessage(PrintSettings.class, "CTL_Print_settings");
- }
-
- public HelpCtx getHelpCtx() {
- return new HelpCtx(HELP_ID);
- }
-
- /** @return an instance of PageFormat
- * The returned page format is either previously set by
- * PageSetupAction or is acquired as a default PageFormat
- * from supported PrinterJob
- */
- public static PageFormat getPageFormat(PrinterJob pj) {
- if (pageFormat == null) {
- pageFormat = pj.defaultPage();
- }
-
- return pageFormat;
- }
-
- /** @deprecated Use {@link #getPageFormat(PrinterJob)} instead. */
- @Deprecated
- public PageFormat getPageFormat() {
- if (pageFormat == null) {
- PrinterJob pj = PrinterJob.getPrinterJob();
- pageFormat = pj.defaultPage(new PageFormat());
- pj.cancel();
- }
-
- return pageFormat;
- }
-
- /** sets page format */
- public void setPageFormat(PageFormat pf) {
- if (pf == null) {
- return;
- }
-
- if (pf.equals(pageFormat)) {
- return;
- }
-
- PageFormat old = pageFormat;
- pageFormat = pf;
- firePropertyChange(PROP_PAGE_FORMAT, old, pageFormat);
- }
-
- public boolean getWrap() {
- return wrap;
- }
-
- public void setWrap(boolean b) {
- if (wrap == b) {
- return;
- }
-
- wrap = b;
- firePropertyChange(PROP_WRAP, (b ? Boolean.FALSE : Boolean.TRUE), (b ? Boolean.TRUE : Boolean.FALSE));
- }
-
- public String getHeaderFormat() {
- if (headerFormat == null) {
- headerFormat = NbBundle.getMessage(PrintSettings.class, "CTL_Header_format");
- }
-
- return headerFormat;
- }
-
- public void setHeaderFormat(String s) {
- if (s == null) {
- return;
- }
-
- if (s.equals(headerFormat)) {
- return;
- }
-
- String of = headerFormat;
- headerFormat = s;
- firePropertyChange(PROP_HEADER_FORMAT, of, headerFormat);
- }
-
- public String getFooterFormat() {
- if (footerFormat == null) {
- footerFormat = NbBundle.getMessage(PrintSettings.class, "CTL_Footer_format");
- }
-
- return footerFormat;
- }
-
- public void setFooterFormat(String s) {
- if (s == null) {
- return;
- }
-
- if (s.equals(footerFormat)) {
- return;
- }
-
- String of = footerFormat;
- footerFormat = s;
- firePropertyChange(PROP_FOOTER_FORMAT, of, footerFormat);
- }
-
- public Font getHeaderFont() {
- if (headerFont == null) {
- headerFont = new Font("Monospaced", java.awt.Font.PLAIN, 6); // NOI18N
- }
-
- return headerFont;
- }
-
- public void setHeaderFont(Font f) {
- if (f == null) {
- return;
- }
-
- if (f.equals(headerFont)) {
- return;
- }
-
- Font old = headerFont;
- headerFont = f;
- firePropertyChange(PROP_HEADER_FONT, old, headerFont);
- }
-
- public Font getFooterFont() {
- if (footerFont == null) {
- footerFont = getHeaderFont();
- }
-
- return footerFont;
- }
-
- public void setFooterFont(Font f) {
- if (f == null) {
- return;
- }
-
- if (f.equals(footerFont)) {
- return;
- }
-
- Font old = headerFont;
- footerFont = f;
- firePropertyChange(PROP_FOOTER_FONT, old, footerFont);
- }
-
- public int getHeaderAlignment() {
- return headerAlignment;
- }
-
- public void setHeaderAlignment(int alignment) {
- if (alignment == headerAlignment) {
- return;
- }
-
- if ((alignment != LEFT) && (alignment != CENTER) && (alignment != RIGHT)) {
- throw new IllegalArgumentException();
- }
-
- int old = headerAlignment;
- headerAlignment = alignment;
- firePropertyChange(PROP_HEADER_ALIGNMENT, new Integer(old), new Integer(headerAlignment));
- }
-
- public int getFooterAlignment() {
- return footerAlignment;
- }
-
- public void setFooterAlignment(int alignment) {
- if (alignment == footerAlignment) {
- return;
- }
-
- if ((alignment != LEFT) && (alignment != CENTER) && (alignment != RIGHT)) {
- throw new IllegalArgumentException();
- }
-
- int old = footerAlignment;
- footerAlignment = alignment;
- firePropertyChange(PROP_FOOTER_ALIGNMENT, new Integer(old), new Integer(footerAlignment));
- }
-
- /** Getter for lineAscentCorrection property. */
- public float getLineAscentCorrection() {
- return lineAscentCorrection;
- }
-
- /** Setter for lineAscentCorrection property.
- * @param correction the correction
- * @exception IllegalArgumentException if correction is less than 0.
- */
- public void setLineAscentCorrection(float correction) {
- if (correction == lineAscentCorrection) {
- return;
- } else if (correction < 0) {
- throw new IllegalArgumentException();
- }
-
- float old = lineAscentCorrection;
- lineAscentCorrection = correction;
- firePropertyChange(PROP_LINE_ASCENT_CORRECTION, new Float(old), new Float(lineAscentCorrection));
- }
-
- /** Property editor for alignment properties */
- public static class AlignmentEditor extends java.beans.PropertyEditorSupport {
- private String sCENTER;
- private String sRIGHT;
- private String sLEFT;
- private String[] tags = new String[] {
- sLEFT = NbBundle.getMessage(PrintSettings.class, "CTL_LEFT"),
- sCENTER = NbBundle.getMessage(PrintSettings.class, "CTL_CENTER"),
- sRIGHT = NbBundle.getMessage(PrintSettings.class, "CTL_RIGHT")
- };
-
- public String[] getTags() {
- return tags;
- }
-
- public String getAsText() {
- return tags[((Integer) getValue()).intValue()];
- }
-
- public void setAsText(String s) {
- if (s.equals(sLEFT)) {
- setValue(new Integer(0));
- } else if (s.equals(sCENTER)) {
- setValue(new Integer(1));
- } else {
- setValue(new Integer(2));
- }
- }
- }
-
- /** Property editor for PageFormat instances */
- public static class PageFormatEditor extends java.beans.PropertyEditorSupport {
- /** No text */
- public String getAsText() {
- return null;
- }
-
- /* @return true */
- public boolean supportsCustomEditor() {
- return true;
- }
-
- /**
- * @return null Shows pageDialog, however.
- */
- public java.awt.Component getCustomEditor() {
- PageFormat pf = (PageFormat) getValue();
- PrinterJob pj = PrinterJob.getPrinterJob();
- PageFormat npf = pj.pageDialog(pf);
-
- //setValue(npf);
- PrintSettings.findObject(PrintSettings.class).setPageFormat((PageFormat) npf.clone());
- pj.cancel();
-
- return null;
- }
- }
-}
Index: openide/text/src/org/openide/text/PrintSettingsBeanInfo.java
===================================================================
RCS file: openide/text/src/org/openide/text/PrintSettingsBeanInfo.java
diff -N openide/text/src/org/openide/text/PrintSettingsBeanInfo.java
--- openide/text/src/org/openide/text/PrintSettingsBeanInfo.java 10 Aug 2006 14:58:41 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-package org.openide.text;
-
-
-import java.awt.Image;
-import java.beans.*;
-import org.openide.util.*;
-
-
-/** BeanInfo for PrintSettings.
-*
-* @author Ales Novak
-*/
-public class PrintSettingsBeanInfo extends SimpleBeanInfo {
- /** Returns the PrintSettings' icon */
- public Image getIcon(int type) {
- return Utilities.loadImage("org/openide/text/printSettings.gif"); // NOI18N
- }
-
- /** Descriptor of valid properties
- * @return array of properties
- */
- public PropertyDescriptor[] getPropertyDescriptors() {
- try {
- PropertyDescriptor[] desc = new PropertyDescriptor[] {
- new PropertyDescriptor(PrintSettings.PROP_WRAP, PrintSettings.class), // 0
- new PropertyDescriptor(PrintSettings.PROP_HEADER_FORMAT, PrintSettings.class), // 1
- new PropertyDescriptor(PrintSettings.PROP_FOOTER_FORMAT, PrintSettings.class), // 2
- new PropertyDescriptor(PrintSettings.PROP_HEADER_FONT, PrintSettings.class), // 3
- new PropertyDescriptor(PrintSettings.PROP_FOOTER_FONT, PrintSettings.class), // 4
- new PropertyDescriptor(PrintSettings.PROP_HEADER_ALIGNMENT, PrintSettings.class), // 5
- new PropertyDescriptor(PrintSettings.PROP_FOOTER_ALIGNMENT, PrintSettings.class), // 6
-
- // new PropertyDescriptor(PrintSettings.PROP_PAGE_FORMAT, PrintSettings.class), // 7
- new PropertyDescriptor(PrintSettings.PROP_LINE_ASCENT_CORRECTION, PrintSettings.class) // 8
- };
- desc[0].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_WRAP"));
- desc[0].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_WRAP"));
- desc[1].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_HEADER_FORMAT"));
- desc[1].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_HEADER_FORMAT"));
- desc[2].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_FOOTER_FORMAT"));
- desc[2].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_FOOTER_FORMAT"));
- desc[3].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_HEADER_FONT"));
- desc[3].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_HEADER_FONT"));
- desc[4].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_FOOTER_FONT"));
- desc[4].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_FOOTER_FONT"));
- desc[5].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_HEADER_ALIGNMENT"));
- desc[5].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_HEADER_ALIGNMENT"));
- desc[5].setPropertyEditorClass(PrintSettings.AlignmentEditor.class);
- desc[6].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_FOOTER_ALIGNMENT"));
- desc[6].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_FOOTER_ALIGNMENT"));
- desc[6].setPropertyEditorClass(PrintSettings.AlignmentEditor.class);
-
- /*
- desc[7].setDisplayName(PrintSettings.getString("PROP_PAGE_FORMAT"));
- desc[7].setShortDescription(PrintSettings.getString("HINT_PAGE_FORMAT"));
- desc[7].setPropertyEditorClass(PrintSettings.PageFormatEditor.class);
- */
- desc[7].setDisplayName(NbBundle.getMessage(PrintSettings.class, "PROP_LINE_ASCENT_CORRECTION"));
- desc[7].setShortDescription(NbBundle.getMessage(PrintSettings.class, "HINT_LINE_ASCENT_CORRECTION"));
-
- return desc;
- } catch (IntrospectionException ex) {
- Exceptions.printStackTrace(ex);
-
- return null;
- }
- }
-}
Index: openide/text/test/unit/src/org/openide/text/PrintPreferencesTest.java
===================================================================
RCS file: openide/text/test/unit/src/org/openide/text/PrintPreferencesTest.java
diff -N openide/text/test/unit/src/org/openide/text/PrintPreferencesTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openide/text/test/unit/src/org/openide/text/PrintPreferencesTest.java 23 May 2007 14:45:42 -0000
@@ -0,0 +1,168 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.openide.text;
+
+import java.awt.Font;
+import java.awt.font.TextAttribute;
+import java.util.Iterator;
+import java.util.Map;
+import org.netbeans.junit.NbTestCase;
+import junit.framework.*;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import java.awt.print.PageFormat;
+import java.awt.print.Paper;
+import java.awt.print.PrinterJob;
+import java.util.prefs.Preferences;
+import org.openide.nodes.BeanNode;
+import org.openide.util.NbPreferences;
+
+/**
+ * @author Radek Matous
+ */
+public class PrintPreferencesTest extends NbTestCase {
+ public PrintPreferencesTest(String testName) {
+ super(testName);
+ }
+
+ public void testGetHeaderFont() {
+ Font expResult = PrintPreferences.getHeaderFont();
+ PrintPreferences.setHeaderFont(expResult);
+ Font result = PrintPreferences.getHeaderFont();
+ assertEquals(expResult, result);
+ Font derived = result.deriveFont(java.awt.Font.BOLD,8);
+ PrintPreferences.setHeaderFont(derived);
+ assertEquals(derived, PrintPreferences.getHeaderFont());
+ }
+
+ public void testGetFooterFont() {
+ Font expResult = PrintPreferences.getFooterFont();
+ PrintPreferences.setFooterFont(expResult);
+ Font result = PrintPreferences.getFooterFont();
+ assertEquals(expResult, result);
+ Font derived = result.deriveFont(java.awt.Font.BOLD,8);
+ PrintPreferences.setFooterFont(derived);
+ assertEquals(derived, PrintPreferences.getFooterFont());
+ }
+
+ public void testGetPageFormat() {
+ PrinterJob pj = PrinterJob.getPrinterJob();
+ PageFormat expResult = PrintPreferences.getPageFormat(pj);
+ PrintPreferences.setPageFormat(expResult);
+ PageFormat result = PrintPreferences.getPageFormat(pj);
+ assertEquals(expResult.getHeight(), result.getHeight());
+ assertEquals(expResult.getWidth(), result.getWidth());
+ assertEquals(expResult.getOrientation(), result.getOrientation());
+ assertEquals(expResult.getPaper().getHeight(), result.getPaper().getHeight());
+ assertEquals(expResult.getPaper().getWidth(), result.getPaper().getWidth());
+ assertEquals(expResult.getPaper().getImageableHeight(), result.getPaper().getImageableHeight());
+ assertEquals(expResult.getPaper().getImageableWidth(), result.getPaper().getImageableWidth());
+ assertEquals(expResult.getPaper().getImageableX(), result.getPaper().getImageableX());
+ assertEquals(expResult.getPaper().getImageableY(), result.getPaper().getImageableY());
+
+ double w = expResult.getPaper().getWidth() + 10;
+ double h = expResult.getPaper().getHeight() + 10;
+ Paper p = expResult.getPaper();
+ double ix = p.getImageableX() + 10;
+ double iy = p.getImageableY() + 10;
+ double iw = p.getImageableWidth() + 10;
+ double ih = p.getImageableHeight() + 10;
+ p.setImageableArea(ix, iy, iw, ih);
+ p.setSize(w, h);
+ expResult.setPaper(p);
+ PrintPreferences.setPageFormat(expResult);
+ assertEquals(h, PrintPreferences.getPageFormat(pj).getHeight());
+ assertEquals(w, PrintPreferences.getPageFormat(pj).getWidth());
+ assertEquals(ix, PrintPreferences.getPageFormat(pj).getPaper().getImageableX());
+ assertEquals(iy, PrintPreferences.getPageFormat(pj).getPaper().getImageableY());
+ assertEquals(iw, PrintPreferences.getPageFormat(pj).getPaper().getImageableWidth());
+ assertEquals(ih, PrintPreferences.getPageFormat(pj).getPaper().getImageableHeight());
+
+ expResult.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+ PrintPreferences.setPageFormat(expResult);
+ assertEquals(PageFormat.REVERSE_LANDSCAPE, PrintPreferences.getPageFormat(pj).getOrientation());
+ }
+
+ public void testGetWrap() {
+ PrintPreferences.setWrap(true);
+ assertEquals(true, PrintPreferences.getWrap());
+ PrintPreferences.setWrap(false);
+ assertEquals(false, PrintPreferences.getWrap());
+ }
+
+ public void testGetHeaderFormat() {
+ String expResult = "my header format";
+ PrintPreferences.setHeaderFormat(expResult);
+ String result = PrintPreferences.getHeaderFormat();
+ assertEquals(expResult, result);
+ }
+
+ public void testGetFooterFormat() {
+ String expResult = "my footer format";
+ PrintPreferences.setFooterFormat(expResult);
+ String result = PrintPreferences.getFooterFormat();
+ assertEquals(expResult, result);
+ }
+
+ public void testGetHeaderAlignment() {
+ PrintPreferences.Alignment expResult = PrintPreferences.Alignment.LEFT;
+ PrintPreferences.setHeaderAlignment(expResult);
+ PrintPreferences.Alignment result = PrintPreferences.getHeaderAlignment();
+ assertEquals(expResult, result);
+
+ expResult = PrintPreferences.Alignment.RIGHT;
+ PrintPreferences.setHeaderAlignment(expResult);
+ result = PrintPreferences.getHeaderAlignment();
+ assertEquals(expResult, result);
+
+ expResult = PrintPreferences.Alignment.CENTER;
+ PrintPreferences.setHeaderAlignment(expResult);
+ result = PrintPreferences.getHeaderAlignment();
+ assertEquals(expResult, result);
+ }
+
+ public void testGetFooterAlignment() {
+ PrintPreferences.Alignment expResult = PrintPreferences.Alignment.LEFT;
+ PrintPreferences.setFooterAlignment(expResult);
+ PrintPreferences.Alignment result = PrintPreferences.getFooterAlignment();
+ assertEquals(expResult, result);
+
+ expResult = PrintPreferences.Alignment.RIGHT;
+ PrintPreferences.setFooterAlignment(expResult);
+ result = PrintPreferences.getFooterAlignment();
+ assertEquals(expResult, result);
+
+ expResult = PrintPreferences.Alignment.CENTER;
+ PrintPreferences.setFooterAlignment(expResult);
+ result = PrintPreferences.getFooterAlignment();
+ assertEquals(expResult, result);
+
+ }
+
+ public void testGetLineAscentCorrection() {
+ float expResult = 0.0F;
+ for (int i = 0; i < 10; i++) {
+ expResult += 1;
+ PrintPreferences.setLineAscentCorrection(expResult);
+ float result = PrintPreferences.getLineAscentCorrection();
+ assertEquals(expResult, result);
+ }
+ }
+}
Index: platform/samples/audio-files/nbproject/project.xml
===================================================================
RCS file: /cvs/platform/samples/audio-files/nbproject/project.xml,v
retrieving revision 1.3
diff -u -6 -r1.3 project.xml
--- platform/samples/audio-files/nbproject/project.xml 30 Jun 2006 14:12:56 -0000 1.3
+++ platform/samples/audio-files/nbproject/project.xml 23 May 2007 14:45:45 -0000
@@ -63,13 +63,13 @@