< prev index next >
src/demo/share/jfc/Font2DTest/Font2DTest.java
Print this page
*** 65,75 ****
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
- import java.util.EnumSet;
import java.util.StringTokenizer;
import java.util.BitSet;
import javax.swing.*;
import javax.swing.event.*;
--- 65,74 ----
*** 99,110 ****
private final ChoiceV2 textMenu;
private int currentTextChoice = 0;
private final ChoiceV2 transformMenu;
private final ChoiceV2 transformMenuG2;
private final ChoiceV2 methodsMenu;
! private final JComboBox antiAliasMenu;
! private final JComboBox fracMetricsMenu;
private final JSlider contrastSlider;
/// CheckboxMenuItems
private CheckboxMenuItemV2 displayGridCBMI;
--- 98,109 ----
private final ChoiceV2 textMenu;
private int currentTextChoice = 0;
private final ChoiceV2 transformMenu;
private final ChoiceV2 transformMenuG2;
private final ChoiceV2 methodsMenu;
! private final JComboBox<FontPanel.AAValues> antiAliasMenu;
! private final JComboBox<FontPanel.FMValues> fracMetricsMenu;
private final JSlider contrastSlider;
/// CheckboxMenuItems
private CheckboxMenuItemV2 displayGridCBMI;
*** 149,162 ****
transformMenu = new ChoiceV2( this );
transformMenuG2 = new ChoiceV2( this );
methodsMenu = new ChoiceV2( this );
antiAliasMenu =
! new JComboBox(EnumSet.allOf(FontPanel.AAValues.class).toArray());
antiAliasMenu.addActionListener(this);
fracMetricsMenu =
! new JComboBox(EnumSet.allOf(FontPanel.FMValues.class).toArray());
fracMetricsMenu.addActionListener(this);
contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250,
FontPanel.getDefaultLCDContrast().intValue());
contrastSlider.setEnabled(false);
--- 148,161 ----
transformMenu = new ChoiceV2( this );
transformMenuG2 = new ChoiceV2( this );
methodsMenu = new ChoiceV2( this );
antiAliasMenu =
! new JComboBox<>(FontPanel.AAValues.values());
antiAliasMenu.addActionListener(this);
fracMetricsMenu =
! new JComboBox<>(FontPanel.FMValues.values());
fracMetricsMenu.addActionListener(this);
contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250,
FontPanel.getDefaultLCDContrast().intValue());
contrastSlider.setEnabled(false);
*** 357,367 ****
userTextDialog.getContentPane().add( "Center", userTextAreaSP );
userTextDialog.getContentPane().add( "South", dialogBottomPanel );
userTextDialog.pack();
userTextDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! userTextDialog.hide();
}
});
/// Prepare printing dialog...
printCBGroup = new ButtonGroup();
--- 356,366 ----
userTextDialog.getContentPane().add( "Center", userTextAreaSP );
userTextDialog.getContentPane().add( "South", dialogBottomPanel );
userTextDialog.pack();
userTextDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! userTextDialog.setVisible(false);
}
});
/// Prepare printing dialog...
printCBGroup = new ButtonGroup();
*** 383,393 ****
printDialog = new JDialog( parent, "Print...", true );
printDialog.setResizable( false );
printDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! printDialog.hide();
}
});
printDialog.getContentPane().setLayout( new GridLayout( printModeCBs.length + 2, 1 ));
printDialog.getContentPane().add( l );
for ( int i = 0; i < printModeCBs.length; i++ ) {
--- 382,392 ----
printDialog = new JDialog( parent, "Print...", true );
printDialog.setResizable( false );
printDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! printDialog.setVisible(false);
}
});
printDialog.getContentPane().setLayout( new GridLayout( printModeCBs.length + 2, 1 ));
printDialog.getContentPane().add( l );
for ( int i = 0; i < printModeCBs.length; i++ ) {
*** 400,410 ****
/// Prepare font information dialog...
fontInfoDialog = new JDialog( parent, "Font info", false );
fontInfoDialog.setResizable( false );
fontInfoDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! fontInfoDialog.hide();
showFontInfoCBMI.setState( false );
}
});
JPanel fontInfoPanel = new JPanel();
fontInfoPanel.setLayout( new GridLayout( fontInfos.length, 1 ));
--- 399,409 ----
/// Prepare font information dialog...
fontInfoDialog = new JDialog( parent, "Font info", false );
fontInfoDialog.setResizable( false );
fontInfoDialog.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
! fontInfoDialog.setVisible(false);
showFontInfoCBMI.setState( false );
}
});
JPanel fontInfoPanel = new JPanel();
fontInfoPanel.setLayout( new GridLayout( fontInfos.length, 1 ));
*** 465,475 ****
}
int style = fontStyles[styleMenu.getSelectedIndex()];
Font f;
for (int i = 0; i < listCount; i++) {
! String fontName = (String)fontMenu.getItemAt(i);
f = new Font(fontName, style, size);
if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX) &&
canDisplayRange(f, rangeStart, rangeEnd)) {
fontMenu.setBit(i, true);
}
--- 464,474 ----
}
int style = fontStyles[styleMenu.getSelectedIndex()];
Font f;
for (int i = 0; i < listCount; i++) {
! String fontName = fontMenu.getItemAt(i);
f = new Font(fontName, style, size);
if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX) &&
canDisplayRange(f, rangeStart, rangeEnd)) {
fontMenu.setBit(i, true);
}
*** 671,683 ****
private void updateGUI() {
int selectedText = textMenu.getSelectedIndex();
/// Set the visibility of User Text dialog
if ( selectedText == fp.USER_TEXT )
! userTextDialog.show();
else
! userTextDialog.hide();
/// Change the visibility/status/availability of Print JDialog buttons
printModeCBs[ fp.ONE_PAGE ].setSelected( true );
if ( selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT ) {
/// ABP
/// update methodsMenu to show that TextLayout.draw is being used
--- 670,682 ----
private void updateGUI() {
int selectedText = textMenu.getSelectedIndex();
/// Set the visibility of User Text dialog
if ( selectedText == fp.USER_TEXT )
! userTextDialog.setVisible(true);
else
! userTextDialog.setVisible(false);
/// Change the visibility/status/availability of Print JDialog buttons
printModeCBs[ fp.ONE_PAGE ].setSelected( true );
if ( selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT ) {
/// ABP
/// update methodsMenu to show that TextLayout.draw is being used
*** 791,804 ****
textToUseOpt, drawMethodOpt,
antialiasOpt, fractionalOpt,
lcdContrast, userTextOpt );
if ( showFontInfoOpt ) {
fireUpdateFontInfo();
! fontInfoDialog.show();
}
else
! fontInfoDialog.hide();
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load Options File; See Stack Trace", true );
ex.printStackTrace();
}
--- 790,803 ----
textToUseOpt, drawMethodOpt,
antialiasOpt, fractionalOpt,
lcdContrast, userTextOpt );
if ( showFontInfoOpt ) {
fireUpdateFontInfo();
! fontInfoDialog.setVisible(true);
}
else
! fontInfoDialog.setVisible(false);
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load Options File; See Stack Trace", true );
ex.printStackTrace();
}
*** 817,827 ****
public void windowClosing( WindowEvent e ) {
( (JFrame) e.getSource() ).dispose();
}
});
f.pack();
! f.show();
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
ex.printStackTrace();
}
--- 816,826 ----
public void windowClosing( WindowEvent e ) {
( (JFrame) e.getSource() ).dispose();
}
});
f.pack();
! f.setVisible(true);
}
catch ( Exception ex ) {
fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
ex.printStackTrace();
}
*** 859,869 ****
loadComparisonPNG( fileName );
}
else if ( itemName.equals( "Page Setup..." ))
fp.doPageSetup();
else if ( itemName.equals( "Print..." ))
! printDialog.show();
else if ( itemName.equals( "Close" ))
parent.dispose();
else if ( itemName.equals( "Exit" ))
System.exit(0);
}
--- 858,868 ----
loadComparisonPNG( fileName );
}
else if ( itemName.equals( "Page Setup..." ))
fp.doPageSetup();
else if ( itemName.equals( "Print..." ))
! printDialog.setVisible(true);
else if ( itemName.equals( "Close" ))
parent.dispose();
else if ( itemName.equals( "Exit" ))
System.exit(0);
}
*** 891,913 ****
String itemName = ( (JButton) source ).getText();
/// Print dialog buttons...
if ( itemName.equals( "Print" )) {
for ( int i = 0; i < printModeCBs.length; i++ )
if ( printModeCBs[i].isSelected() ) {
! printDialog.hide();
fp.doPrint( i );
}
}
else if ( itemName.equals( "Cancel" ))
! printDialog.hide();
/// Update button from Usert Text JDialog...
else if ( itemName.equals( "Update" ))
fp.setTextToDraw( fp.USER_TEXT, null,
parseUserText( userTextArea.getText() ), null );
}
else if ( source instanceof JComboBox ) {
! JComboBox c = (JComboBox) source;
/// RangeMenu handles actions by itself and then calls fireRangeChanged,
/// so it is not listed or handled here
if ( c == fontMenu || c == styleMenu || c == transformMenu ) {
float sz = 12f;
--- 890,912 ----
String itemName = ( (JButton) source ).getText();
/// Print dialog buttons...
if ( itemName.equals( "Print" )) {
for ( int i = 0; i < printModeCBs.length; i++ )
if ( printModeCBs[i].isSelected() ) {
! printDialog.setVisible(false);
fp.doPrint( i );
}
}
else if ( itemName.equals( "Cancel" ))
! printDialog.setVisible(false);
/// Update button from Usert Text JDialog...
else if ( itemName.equals( "Update" ))
fp.setTextToDraw( fp.USER_TEXT, null,
parseUserText( userTextArea.getText() ), null );
}
else if ( source instanceof JComboBox ) {
! JComboBox<?> c = (JComboBox<?>) source;
/// RangeMenu handles actions by itself and then calls fireRangeChanged,
/// so it is not listed or handled here
if ( c == fontMenu || c == styleMenu || c == transformMenu ) {
float sz = 12f;
*** 994,1007 ****
else if ( cbmi == force16ColsCBMI )
fp.setForce16Columns( force16ColsCBMI.getState() );
else if ( cbmi == showFontInfoCBMI ) {
if ( showFontInfoCBMI.getState() ) {
fireUpdateFontInfo();
! fontInfoDialog.show();
}
else
! fontInfoDialog.hide();
}
}
}
private static void printUsage() {
--- 993,1006 ----
else if ( cbmi == force16ColsCBMI )
fp.setForce16Columns( force16ColsCBMI.getState() );
else if ( cbmi == showFontInfoCBMI ) {
if ( showFontInfoCBMI.getState() ) {
fireUpdateFontInfo();
! fontInfoDialog.setVisible(true);
}
else
! fontInfoDialog.setVisible(false);
}
}
}
private static void printUsage() {
*** 1037,1047 ****
public void windowClosing( WindowEvent e ) { System.exit(0); }
});
f.getContentPane().add( f2dt );
f.pack();
! f.show();
}
/// Inner class definitions...
/// Class to display just an image file
--- 1036,1046 ----
public void windowClosing( WindowEvent e ) { System.exit(0); }
});
f.getContentPane().add( f2dt );
f.pack();
! f.setVisible(true);
}
/// Inner class definitions...
/// Class to display just an image file
*** 1068,1078 ****
super( name );
this.addActionListener( al );
}
}
! private final class ChoiceV2 extends JComboBox {
private BitSet bitSet = null;
public ChoiceV2() {;}
--- 1067,1077 ----
super( name );
this.addActionListener( al );
}
}
! private final class ChoiceV2 extends JComboBox<String> {
private BitSet bitSet = null;
public ChoiceV2() {;}
*** 1139,1149 ****
yesImage = new ImageIcon(yes);
blankImage = new ImageIcon(blank);
this.choice = choice;
}
! public Component getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
--- 1138,1148 ----
yesImage = new ImageIcon(yes);
blankImage = new ImageIcon(blank);
this.choice = choice;
}
! public Component getListCellRendererComponent(JList<?> list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
< prev index next >