2362N/A * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * Redistribution and use in source and binary forms, with or without 0N/A * modification, are permitted provided that the following conditions 0N/A * - Redistributions of source code must retain the above copyright 0N/A * notice, this list of conditions and the following disclaimer. 0N/A * - Redistributions in binary form must reproduce the above copyright 0N/A * notice, this list of conditions and the following disclaimer in the 0N/A * documentation and/or other materials provided with the distribution. 2362N/A * - Neither the name of Oracle nor the names of its 0N/A * contributors may be used to endorse or promote products derived 0N/A * from this software without specific prior written permission. 0N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 0N/A * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 0N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 0N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 0N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 0N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 0N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4378N/A * This source code is provided to illustrate the usage of a given feature 4378N/A * or technique and has been deliberately simplified. Additional steps 4378N/A * required for a production-quality application, such as security checks, 4378N/A * input validation and proper error handling, might not be present in 0N/A * @author Shinsuke Fukuda 0N/A * @author Ankit Patel [Conversion to Swing - 01/07/30] 0N/A/// Main Font2DTest Class 0N/A /// JFrame that will contain Font2DTest 0N/A /// FontPanel class that will contain all graphical output 0N/A /// RangeMenu class that contains info about the unicode ranges 0N/A /// Other menus to set parameters for text drawing 0N/A /// CheckboxMenuItems 0N/A // Enabled or disabled status of canDisplay check 0N/A /// Initialize GUI variables and its layouts 0N/A /// Set up the main interface panel 0N/A /// Adds a component to a container with a label to its left in GridBagLayout 0N/A /// Sets up menu entries 0N/A /// Sets up the all dialogs used in Font2DTest... 0N/A /// Prepare user text dialog... 0N/A /// Prepare printing dialog... 0N/A new LabelV2(
"Note: Page range in native \"Print\" dialog will not affect the result" );
0N/A /// Prepare font information dialog... 0N/A /// Move the location of the dialog... 0N/A /// RangeMenu object signals using this function 0N/A /// when Unicode range has been changed and text needs to be redrawn 0N/A /// Changes the message on the status bar 0N/A /// If this is not ran as an applet, use own status bar, 0N/A /// Updates the information about the selected font 0N/A /// Displays a file load/save dialog and returns the specified file 0N/A /// Converts user text into arrays of String, delimited at newline character 0N/A /// Also replaces any valid escape sequence with appropriate unicode character 0N/A /// Support \\UXXXXXX notation for surrogates 0N/A /// Reads the text from specified file, detecting UTF-16 encoding 0N/A /// Then breaks the text into String array, delimited at every line break 0N/A /// If byte mark is found, then use UTF-16 encoding to convert bytes... 0N/A /// Otherwise, use system default encoding 0N/A /// Determine "Return Char" used in this file 0N/A /// This simply finds first occurrence of CR, CR+LF or LF... 0N/A /// Use the one already created 0N/A /// To make LineBreakMeasurer to return a valid TextLayout 0N/A /// on an empty line, simply feed it a space char... 0N/A /// Returns a String storing current configuration 0N/A /// Prepend title and the option that is only obtainable here 0N/A (
"Font2DTest Option File\n" +
0N/A /// Set the visibility of User Text dialog 0N/A /// update methodsMenu to show that TextLayout.draw is being used 0N/A /// when we are in FILE_TEXT mode 0N/A /// update methodsMenu to show that drawGlyph is being used 0N/A /// when we are in ALL_GLYPHS mode 0N/A /// Modify RangeMenu and fontInfo label availabilty 0N/A /// Loads saved options and applies them 0N/A /// Parse all options 0N/A /// Reset option variables and repaint 0N/A /// Loads a previously saved image 0N/A /// Interface functions... 0N/A /// ActionListener interface function 0N/A /// Responds to JMenuItem, JTextField and JButton actions 0N/A /// Print dialog buttons... 0N/A /// Update button from Usert Text JDialog... 0N/A /// RangeMenu handles actions by itself and then calls fireRangeChanged, 0N/A /// so it is not listed or handled here 0N/A /// User cancelled selection; reset to previous choice 0N/A /// ItemListener interface function 0N/A /// Responds to JCheckBoxMenuItem, JComboBox and JCheckBox actions 0N/A "\nwhere options include:\n" +
0N/A " -dcdc | -disablecandisplaycheck disable canDisplay check for font\n" +
0N/A " -? | -help print this help message\n" +
0N/A " To disable canDisplay check on font for ranges\n" +
0N/A " java -jar Font2DTest.jar -dcdc";
0N/A /// Inner class definitions... 0N/A /// Class to display just an image file 0N/A /// Used to show the comparison PNG image 0N/A /// Classes made to avoid repetitive calls... (being lazy) 0N/A //Register this component in ToolTipManager 0N/A return "Font \"" +
fontName +
"\" can display some characters in \"" +
0N/A return "Font \"" +
fontName +
"\" cannot display any characters in \"" +
0N/A //For JComboBox if index is -1, its rendering the selected index.