< prev index next >
src/demo/share/jfc/Font2DTest/Font2DTest.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
--- 1,7 ----
/*
! * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*** 114,133 ****
/// JDialog boxes
private JDialog userTextDialog;
private JTextArea userTextArea;
private JDialog printDialog;
private JDialog fontInfoDialog;
! private LabelV2 fontInfos[] = new LabelV2[2];
private JFileChooser filePromptDialog = null;
private ButtonGroup printCBGroup;
! private JRadioButton printModeCBs[] = new JRadioButton[3];
/// Status bar
private final LabelV2 statusBar;
! private int fontStyles [] = {Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC};
/// Text filename
private String tFileName;
// Enabled or disabled status of canDisplay check
--- 114,133 ----
/// JDialog boxes
private JDialog userTextDialog;
private JTextArea userTextArea;
private JDialog printDialog;
private JDialog fontInfoDialog;
! private LabelV2[] fontInfos = new LabelV2[2];
private JFileChooser filePromptDialog = null;
private ButtonGroup printCBGroup;
! private JRadioButton[] printModeCBs = new JRadioButton[3];
/// Status bar
private final LabelV2 statusBar;
! private int[] fontStyles = {Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC};
/// Text filename
private String tFileName;
// Enabled or disabled status of canDisplay check
*** 287,297 ****
mb.add( fileMenu );
mb.add( optionMenu );
parent.setJMenuBar( mb );
! String fontList[] =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for ( int i = 0; i < fontList.length; i++ )
fontMenu.addItem( fontList[i] );
fontMenu.setSelectedItem( "Dialog" );
--- 287,297 ----
mb.add( fileMenu );
mb.add( optionMenu );
parent.setJMenuBar( mb );
! String[] fontList =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for ( int i = 0; i < fontList.length; i++ )
fontMenu.addItem( fontList[i] );
fontMenu.setSelectedItem( "Dialog" );
*** 420,430 ****
}
/// RangeMenu object signals using this function
/// when Unicode range has been changed and text needs to be redrawn
public void fireRangeChanged() {
! int range[] = rm.getSelectedRange();
fp.setTextToDraw( fp.RANGE_TEXT, range, null, null );
if(canDisplayCheck) {
setupFontList(range[0], range[1]);
}
if ( showFontInfoCBMI.getState() )
--- 420,430 ----
}
/// RangeMenu object signals using this function
/// when Unicode range has been changed and text needs to be redrawn
public void fireRangeChanged() {
! int[] range = rm.getSelectedRange();
fp.setTextToDraw( fp.RANGE_TEXT, range, null, null );
if(canDisplayCheck) {
setupFontList(range[0], range[1]);
}
if ( showFontInfoCBMI.getState() )
*** 443,453 ****
}
/// Updates the information about the selected font
public void fireUpdateFontInfo() {
if ( showFontInfoCBMI.getState() ) {
! String infos[] = fp.getFontInfo();
for ( int i = 0; i < fontInfos.length; i++ )
fontInfos[i].setText( infos[i] );
fontInfoDialog.pack();
}
}
--- 443,453 ----
}
/// Updates the information about the selected font
public void fireUpdateFontInfo() {
if ( showFontInfoCBMI.getState() ) {
! String[] infos = fp.getFontInfo();
for ( int i = 0; i < fontInfos.length; i++ )
fontInfos[i].setText( infos[i] );
fontInfoDialog.pack();
}
}
*** 531,541 ****
/// Also replaces any valid escape sequence with appropriate unicode character
/// Support \\UXXXXXX notation for surrogates
private String[] parseUserText( String orig ) {
int length = orig.length();
StringTokenizer perLine = new StringTokenizer( orig, "\n" );
! String textLines[] = new String[ perLine.countTokens() ];
int lineNumber = 0;
while ( perLine.hasMoreElements() ) {
StringBuffer converted = new StringBuffer();
String oneLine = perLine.nextToken();
--- 531,541 ----
/// Also replaces any valid escape sequence with appropriate unicode character
/// Support \\UXXXXXX notation for surrogates
private String[] parseUserText( String orig ) {
int length = orig.length();
StringTokenizer perLine = new StringTokenizer( orig, "\n" );
! String[] textLines = new String[ perLine.countTokens() ];
int lineNumber = 0;
while ( perLine.hasMoreElements() ) {
StringBuffer converted = new StringBuffer();
String oneLine = perLine.nextToken();
*** 581,598 ****
/// Reads the text from specified file, detecting UTF-16 encoding
/// Then breaks the text into String array, delimited at every line break
private void readTextFile( String fileName ) {
try {
! String fileText, textLines[];
BufferedInputStream bis =
new BufferedInputStream( new FileInputStream( fileName ));
int numBytes = bis.available();
if (numBytes == 0) {
throw new Exception("Text file " + fileName + " is empty");
}
! byte byteData[] = new byte[ numBytes ];
bis.read( byteData, 0, numBytes );
bis.close();
/// If byte mark is found, then use UTF-16 encoding to convert bytes...
if (numBytes >= 2 &&
--- 581,598 ----
/// Reads the text from specified file, detecting UTF-16 encoding
/// Then breaks the text into String array, delimited at every line break
private void readTextFile( String fileName ) {
try {
! String fileText;String[] textLines;
BufferedInputStream bis =
new BufferedInputStream( new FileInputStream( fileName ));
int numBytes = bis.available();
if (numBytes == 0) {
throw new Exception("Text file " + fileName + " is empty");
}
! byte[] byteData = new byte[ numBytes ];
bis.read( byteData, 0, numBytes );
bis.close();
/// If byte mark is found, then use UTF-16 encoding to convert bytes...
if (numBytes >= 2 &&
*** 646,664 ****
try {
String curOptions = fp.getCurrentOptions();
BufferedOutputStream bos =
new BufferedOutputStream( new FileOutputStream( fileName ));
/// Prepend title and the option that is only obtainable here
! int range[] = rm.getSelectedRange();
String completeOptions =
( "Font2DTest Option File\n" +
displayGridCBMI.getState() + "\n" +
force16ColsCBMI.getState() + "\n" +
showFontInfoCBMI.getState() + "\n" +
rm.getSelectedItem() + "\n" +
range[0] + "\n" + range[1] + "\n" + curOptions + tFileName);
! byte toBeWritten[] = completeOptions.getBytes( "UTF-16" );
bos.write( toBeWritten, 0, toBeWritten.length );
bos.close();
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Save Options File; See Stack Trace", true );
--- 646,664 ----
try {
String curOptions = fp.getCurrentOptions();
BufferedOutputStream bos =
new BufferedOutputStream( new FileOutputStream( fileName ));
/// Prepend title and the option that is only obtainable here
! int[] range = rm.getSelectedRange();
String completeOptions =
( "Font2DTest Option File\n" +
displayGridCBMI.getState() + "\n" +
force16ColsCBMI.getState() + "\n" +
showFontInfoCBMI.getState() + "\n" +
rm.getSelectedItem() + "\n" +
range[0] + "\n" + range[1] + "\n" + curOptions + tFileName);
! byte[] toBeWritten = completeOptions.getBytes( "UTF-16" );
bos.write( toBeWritten, 0, toBeWritten.length );
bos.close();
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Save Options File; See Stack Trace", true );
*** 712,722 ****
private void loadOptions( String fileName ) {
try {
BufferedInputStream bis =
new BufferedInputStream( new FileInputStream( fileName ));
int numBytes = bis.available();
! byte byteData[] = new byte[ numBytes ];
bis.read( byteData, 0, numBytes );
bis.close();
if ( numBytes < 2 ||
(byteData[0] != (byte) 0xFE || byteData[1] != (byte) 0xFF) )
throw new Exception( "Not a Font2DTest options file" );
--- 712,722 ----
private void loadOptions( String fileName ) {
try {
BufferedInputStream bis =
new BufferedInputStream( new FileInputStream( fileName ));
int numBytes = bis.available();
! byte[] byteData = new byte[ numBytes ];
bis.read( byteData, 0, numBytes );
bis.close();
if ( numBytes < 2 ||
(byteData[0] != (byte) 0xFE || byteData[1] != (byte) 0xFF) )
throw new Exception( "Not a Font2DTest options file" );
*** 742,752 ****
int textToUseOpt = Integer.parseInt( perLine.nextToken() );
int drawMethodOpt = Integer.parseInt( perLine.nextToken() );
int antialiasOpt = Integer.parseInt(perLine.nextToken());
int fractionalOpt = Integer.parseInt(perLine.nextToken());
int lcdContrast = Integer.parseInt(perLine.nextToken());
! String userTextOpt[] = { "Font2DTest!" };
String dialogEntry = "Font2DTest!";
if (textToUseOpt == fp.USER_TEXT ) {
int numLines = perLine.countTokens(), lineNumber = 0;
if ( numLines != 0 ) {
userTextOpt = new String[ numLines ];
--- 742,752 ----
int textToUseOpt = Integer.parseInt( perLine.nextToken() );
int drawMethodOpt = Integer.parseInt( perLine.nextToken() );
int antialiasOpt = Integer.parseInt(perLine.nextToken());
int fractionalOpt = Integer.parseInt(perLine.nextToken());
int lcdContrast = Integer.parseInt(perLine.nextToken());
! String[] userTextOpt = { "Font2DTest!" };
String dialogEntry = "Font2DTest!";
if (textToUseOpt == fp.USER_TEXT ) {
int numLines = perLine.countTokens(), lineNumber = 0;
if ( numLines != 0 ) {
userTextOpt = new String[ numLines ];
*** 1014,1024 ****
System.out.println(usage);
System.exit(0);
}
/// Main function
! public static void main(String argv[]) {
if(argv.length > 0) {
if(argv[0].equalsIgnoreCase("-disablecandisplaycheck") ||
argv[0].equalsIgnoreCase("-dcdc")) {
canDisplayCheck = false;
--- 1014,1024 ----
System.out.println(usage);
System.exit(0);
}
/// Main function
! public static void main(String[] argv) {
if(argv.length > 0) {
if(argv[0].equalsIgnoreCase("-disablecandisplaycheck") ||
argv[0].equalsIgnoreCase("-dcdc")) {
canDisplayCheck = false;
< prev index next >