< prev index next >
src/demo/share/jfc/Font2DTest/FontPanel.java
Print this page
@@ -72,11 +72,10 @@
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.text.AttributedString;
-import java.util.EnumSet;
import java.util.Vector;
import javax.imageio.*;
import javax.swing.*;
@@ -390,11 +389,11 @@
}
setFontParams( name, size, style, transform );
setTransformG2( g2transform ); // ABP
setDrawMethod( method );
setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm),
- new Integer(contrast));
+ Integer.valueOf(contrast));
}
/// Writes the current screen to PNG file
public void doSavePNG( String fileName ) {
fc.writePNG( fileName );
@@ -432,11 +431,11 @@
/// Offset from the top left edge of the canvas where the draw will start
private int canvasInset_X = 5, canvasInset_Y = 5;
/// LineBreak'ed TextLayout vector
- private Vector lineBreakTLs = null;
+ private Vector<TextLayout> lineBreakTLs = null;
/// Whether the current draw command requested is for printing
private boolean isPrinting = false;
/// Other printing infos
@@ -798,11 +797,11 @@
/// If this is text loaded from file, prepares the LineBreak'ed
/// text layout at this point
if ( textToUse == FILE_TEXT ) {
if ( !isPrinting )
f2dt.fireChangeStatus( "LineBreaking Text... Please Wait", false );
- lineBreakTLs = new Vector();
+ lineBreakTLs = new Vector<>();
for ( int i = 0; i < fileText.length; i++ ) {
AttributedString as =
new AttributedString( fileText[i], g2.getFont().getAttributes() );
LineBreakMeasurer lbm =
@@ -927,11 +926,11 @@
}
else {
float xPos, yPos = (float) canvasInset_Y;
g2.drawRect( 0, 0, w - 1, h - 1 );
for ( int i = drawStart; i <= drawEnd; i++ ) {
- TextLayout oneLine = (TextLayout) lineBreakTLs.elementAt( i );
+ TextLayout oneLine = lineBreakTLs.elementAt( i );
xPos =
oneLine.isLeftToRight() ?
canvasInset_X : ( (float) w - oneLine.getAdvance() - canvasInset_X );
float[] fmData = {0, oneLine.getAscent(), 0, oneLine.getDescent(), 0, oneLine.getLeading()};
@@ -990,13 +989,13 @@
int pageWidth = (int) pf.getImageableWidth();
int pageHeight = (int) pf.getImageableHeight();
/// Back up metrics and other drawing info before printing modifies it
int backupDrawStart = drawStart, backupDrawEnd = drawEnd;
int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown;
- Vector backupLineBreakTLs = null;
+ Vector<TextLayout> backupLineBreakTLs = null;
if ( textToUse == FILE_TEXT )
- backupLineBreakTLs = (Vector) lineBreakTLs.clone();
+ backupLineBreakTLs = new Vector<>(lineBreakTLs);
printPageNumber = pageIndex;
isPrinting = true;
/// Push the actual draw area 60 down to allow info to be printed
g.translate( (int) pf.getImageableX(), (int) pf.getImageableY() + 60 );
@@ -1135,11 +1134,11 @@
g2.drawRect( 0, 0, zoomAreaWidth, zoomAreaHeight );
modeSpecificDrawChar( g2, currMouseOverChar,
zoomAreaWidth / 2, (int) ( maxAscent * ZOOM ));
g2.dispose();
if ( !nowZooming )
- zoomWindow.show();
+ zoomWindow.setVisible(true);
/// This is sort of redundant... since there is a paint function
/// inside zoomWindow definition that does the drawImage.
/// (I should be able to call just repaint() here)
/// However, for some reason, that paint function fails to respond
/// from second time and on; So I have to force the paint here...
@@ -1174,11 +1173,11 @@
/// MouseListener interface function
/// Redraws the area that was drawn over by zoomed character
public void mouseReleased( MouseEvent e ) {
if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) {
if ( nowZooming )
- zoomWindow.hide();
+ zoomWindow.setVisible(false);
nowZooming = false;
}
this.setCursor( Cursor.getDefaultCursor() );
}
@@ -1244,22 +1243,22 @@
public Object getHint() {
return hint;
}
public static Object getValue(int ordinal) {
if (valArray == null) {
- valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
+ valArray = FMValues.values();
}
for (int i=0;i<valArray.length;i++) {
if (valArray[i].ordinal() == ordinal) {
return valArray[i];
}
}
return valArray[0];
}
private static FMValues[] getArray() {
if (valArray == null) {
- valArray = (FMValues[])EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);
+ valArray = FMValues.values();
}
return valArray;
}
public static int getHintVal(Object hint) {
@@ -1306,11 +1305,11 @@
((AAValues)o).ordinal() >= AALCDHRGB.ordinal());
}
public static Object getValue(int ordinal) {
if (valArray == null) {
- valArray = (AAValues[])EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
+ valArray = AAValues.values();
}
for (int i=0;i<valArray.length;i++) {
if (valArray[i].ordinal() == ordinal) {
return valArray[i];
}
@@ -1318,12 +1317,11 @@
return valArray[0];
}
private static AAValues[] getArray() {
if (valArray == null) {
- Object [] oa = EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);
- valArray = (AAValues[])(EnumSet.allOf(AAValues.class).toArray(new AAValues[0]));
+ valArray = AAValues.values();
}
return valArray;
}
public static int getHintVal(Object hint) {
< prev index next >