Java Code Examples for javax.print.attribute.standard.MediaSize#findMedia()
The following examples show how to use
javax.print.attribute.standard.MediaSize#findMedia() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomMediaSizeName.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 2
Source File: CustomMediaSizeName.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 3
Source File: CustomMediaSizeName.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 4
Source File: CustomMediaSizeName.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 5
Source File: CustomMediaSizeName.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 6
Source File: CustomMediaSizeName.java From Bytecoder with Apache License 2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 7
Source File: CustomMediaSizeName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 8
Source File: CustomMediaSizeName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 9
Source File: PrintUtilities.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets the paper size. * * @param service The {@link PrintService} to use. * @param set The {@link PrintRequestAttributeSet} to use. * @param size The size of the paper. * @param units The type of units being used. */ public static void setPaperSize(PrintService service, PrintRequestAttributeSet set, double[] size, LengthUnits units) { double[] margins = getPaperMargins(service, set, units); MediaSizeName mediaSizeName = MediaSize.findMedia((float) LengthUnits.IN.convert(units, new Fixed6(size[0])).asDouble(), (float) LengthUnits.IN.convert(units, new Fixed6(size[1])).asDouble(), Size2DSyntax.INCH); if (mediaSizeName == null) { mediaSizeName = MediaSizeName.NA_LETTER; } set.add(mediaSizeName); setPaperMargins(service, set, margins, units); }
Example 10
Source File: CustomMediaSizeName.java From hottub with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 11
Source File: CustomMediaSizeName.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } }
Example 12
Source File: CustomMediaSizeName.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } }
Example 13
Source File: CustomMediaSizeName.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 14
Source File: CustomMediaSizeName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }
Example 15
Source File: CustomMediaSizeName.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public CustomMediaSizeName(String name, String choice, float width, float length) { super(nextValue(name)); choiceName = choice; customEnumTable.add(this); mediaName = null; try { mediaName = MediaSize.findMedia(width, length, MediaSize.INCH); } catch (IllegalArgumentException iae) { } // The public API method finds a closest match even if it not // all that close. Here we want to be sure its *really* close. if (mediaName != null) { MediaSize sz = MediaSize.getMediaSizeForName(mediaName); if (sz == null) { mediaName = null; } else { float w = sz.getX(MediaSize.INCH); float h = sz.getY(MediaSize.INCH); float dw = Math.abs(w - width); float dh = Math.abs(h - length); if (dw > 0.1 || dh > 0.1) { mediaName = null; } } } }