/* * Copyright (c) 2000, 2021, 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: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* * This source code is provided to illustrate the usage of a given feature * or technique and has been deliberately simplified. Additional steps * required for a production-quality application, such as security checks, * input validation and proper error handling, might not be present in * this sample code.
*/
public FontPanel( Font2DTest demo, JFrame f ) {
f2dt = demo;
parent = f;
verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
fc = new FontCanvas();
this.setLayout( new BorderLayout() ); this.add( "Center", fc ); this.add( "East", verticalBar );
verticalBar.addAdjustmentListener( this ); this.addComponentListener( new ComponentAdapter() { publicvoid componentResized( ComponentEvent e ) {
updateFontMetrics = true;
}
});
/// Initialize font and its infos
testFont = new Font(fontName, fontStyle, (int)fontSize); if ((float)((int)fontSize) != fontSize) {
testFont = testFont.deriveFont(fontSize);
}
updateFontInfo();
}
public Dimension getPreferredSize() { returnnew Dimension(600, 200);
}
/// Functions called by the main programs to set the various parameters
/// Recreate the font as specified
testFont = new Font(fontName, fontStyle, (int)fontSize); if ((float)((int)fontSize) != fontSize) {
testFont = testFont.deriveFont(fontSize);
}
if ( fontTransform != NONE ) {
AffineTransform at = getAffineTransform( fontTransform );
testFont = testFont.deriveFont( at );
}
updateFontMetrics = true;
fc.repaint(); if ( fontModified ) { /// Tell main panel to update the font info
updateFontInfo();
f2dt.fireUpdateFontInfo();
}
}
/// Prints out the text display area publicvoid doPrint( int i ) { if ( printer == null ) {
printer = PrinterJob.getPrinterJob();
page = printer.defaultPage();
}
printMode = i;
printer.setPrintable( fc, page );
if ( printer.printDialog() ) { try {
printer.print();
} catch ( Exception e ) {
f2dt.fireChangeStatus( "ERROR: Printing Failed; See Stack Trace", true );
}
}
}
/// Displays the page setup dialog and updates PageFormat info publicvoid doPageSetup() { if ( printer == null ) {
printer = PrinterJob.getPrinterJob();
page = printer.defaultPage();
}
page = printer.pageDialog( page );
}
/// Obtains the information about selected font privatevoid updateFontInfo() { int numGlyphs = 0, numCharsInRange = drawRange[1] - drawRange[0] + 1;
fontInfos[0] = "Font Face Name: " + testFont.getFontName();
fontInfos[1] = "Glyphs in This Range: ";
if ( textToUse == RANGE_TEXT ) { for ( int i = drawRange[0]; i < drawRange[1]; i++ ) if ( testFont.canDisplay( i ))
numGlyphs++;
fontInfos[1] = fontInfos[1] + numGlyphs + " / " + numCharsInRange;
} else
fontInfos[1] = null;
}
/// Accessor for the font information public String[] getFontInfo() { return fontInfos;
}
/// Collects the currectly set options and returns them as string public String getCurrentOptions() { /// Create a new String to store the options /// The array will contain all 8 setting (font name, size...) and /// character range or user text data used (no file text data) int userTextSize = 0;
String options;
/// Reload all options and refreshes the canvas publicvoid loadOptions( boolean grid, boolean force16, int start, int end,
String name, float size, int style, int transform, int g2transform, int text, int method, int aa, int fm, int contrast, String[] user ) { int[] range = { start, end };
/// Since repaint call has a low priority, these functions will finish /// before the actual repainting is done
setGridDisplay( grid );
setForce16Columns( force16 ); // previous call to readTextFile has already set the text to draw if (textToUse != FILE_TEXT) {
setTextToDraw( text, range, user, null );
}
setFontParams( name, size, style, transform );
setTransformG2( g2transform ); // ABP
setDrawMethod( method );
setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm),
Integer.valueOf(contrast));
}
/// Writes the current screen to PNG file publicvoid doSavePNG( String fileName ) {
fc.writePNG( fileName );
}
/// When scrolled using the scroll bar, update the backbuffer publicvoid adjustmentValueChanged( AdjustmentEvent e ) {
fc.repaint();
}
publicvoid paintComponent( Graphics g ) { // Windows does not repaint correctly, after // a zoom. Thus, we need to force the canvas // to repaint, but only once. After the first repaint, // everything stabilizes. [ABP]
fc.repaint();
}
/// Inner class definition...
/// Inner panel that holds the actual drawing area and its routines privateclass FontCanvas extends JPanel implements MouseListener, MouseMotionListener, Printable {
/// Number of characters that will fit across and down this canvas privateint numCharAcross, numCharDown;
/// First and last character/line that will be drawn /// Limit is the end of range/text where no more draw will be done privateint drawStart, drawEnd, drawLimit;
/// FontMetrics variables /// Here, gridWidth is equivalent to maxAdvance (slightly bigger though) /// and gridHeight is equivalent to lineHeight privateint maxAscent, maxDescent, gridWidth = 0, gridHeight = 0;
/// Offset from the top left edge of the canvas where the draw will start privateint canvasInset_X = 5, canvasInset_Y = 5;
/// Information about zooming (used with range text draw) privatefinal JWindow zoomWindow; private BufferedImage zoomImage = null; privateint mouseOverCharX = -1, mouseOverCharY = -1; privateint currMouseOverChar = -1, prevZoomChar = -1; privatefloat ZOOM = 2.0f; privateboolean nowZooming = false; privateboolean firstTime = true; // ABP
/// Status bar message backup private String backupStatusString = null;
/// Error constants privatefinal String[] ERRORS = { "ERROR: drawBytes cannot handle characters beyond 0x00FF. Select different range or draw methods.", "ERROR: Cannot fit text with the current font size. Resize the window or use smaller font size.", "ERROR: Cannot print with the current font size. Use smaller font size.",
};
/// Other variables privatefinal Cursor blankCursor;
public FontCanvas() { this.addMouseListener( this ); this.addMouseMotionListener( this ); this.setForeground( Color.black ); this.setBackground( Color.white );
/// Creates an invisble pointer by giving it bogus image /// Possibly find a workaround for this...
Toolkit tk = Toolkit.getDefaultToolkit(); byte[] bogus = { (byte) 0 };
blankCursor =
tk.createCustomCursor( tk.createImage( bogus ), new Point(0, 0), "" );
/// Sets the font, hints, according to the set parameters privatevoid setParams( Graphics2D g2 ) {
g2.setFont( testFont );
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType);
g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType);
g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, lcdContrast); /* I am preserving a somewhat dubious behaviour of this program. * Outline text would be drawn anti-aliased by setting the * graphics anti-aliasing hint if the text anti-aliasing hint * was set. The dubious element here is that people simply * using this program may think this is built-in behaviour * but its not - at least not when the app explicitly draws * outline text. * This becomes more dubious in cases such as "GASP" where the * size at which text is AA'ed is not something you can easily * calculate, so mimicing that behaviour isn't going to be easy. * So I precisely preserve the behaviour : this is done only * if the AA value is "ON". Its not applied in the other cases.
*/ if (antiAliasType == VALUE_TEXT_ANTIALIAS_ON &&
(drawMethod == TL_OUTLINE || drawMethod == GV_OUTLINE)) {
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
} else {
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_OFF);
}
}
/// Draws the grid (Used for unicode/glyph range drawing) privatevoid drawGrid( Graphics2D g2 ) { int totalGridWidth = numCharAcross * gridWidth; int totalGridHeight = numCharDown * gridHeight;
g2.setColor( Color.black ); for ( int i = 0; i < numCharDown + 1; i++ )
g2.drawLine( canvasInset_X, i * gridHeight + canvasInset_Y,
canvasInset_X + totalGridWidth, i * gridHeight + canvasInset_Y ); for ( int i = 0; i < numCharAcross + 1; i++ )
g2.drawLine( i * gridWidth + canvasInset_X, canvasInset_Y,
i * gridWidth + canvasInset_X, canvasInset_Y + totalGridHeight );
}
/// Draws one character at time onto the canvas according to /// the method requested (Used for RANGE_TEXT and ALL_GLYPHS) publicvoid modeSpecificDrawChar( Graphics2D g2, int charCode, int baseX, int baseY ) {
GlyphVector gv; int[] oneGlyph = { charCode }; char[] charArray = Character.toChars( charCode );
/// Create GlyphVector to measure the exact visual advance /// Using that number, adjust the position of the character drawn if ( textToUse == ALL_GLYPHS )
gv = testFont.createGlyphVector( frc, oneGlyph ); else
gv = testFont.createGlyphVector( frc, charArray );
Rectangle2D r2d2 = gv.getPixelBounds(frc, 0, 0); int shiftedX = baseX; // getPixelBounds returns a result in device space. // we need to convert back to user space to be able to // calculate the shift as baseX is in user space. try { double[] pt = newdouble[4];
pt[0] = r2d2.getX();
pt[1] = r2d2.getY();
pt[2] = r2d2.getX()+r2d2.getWidth();
pt[3] = r2d2.getY()+r2d2.getHeight();
oldTX.inverseTransform(pt,0,pt,0,2);
shiftedX = baseX - (int) ( pt[2] / 2 + pt[0] );
} catch (NoninvertibleTransformException e) {
}
/// ABP - keep track of old tform, restore it later
/// Draws one line of text at given position privatevoid modeSpecificDrawLine( Graphics2D g2, String line, int baseX, int baseY ) { /// ABP - keep track of old tform, restore it later
AffineTransform oldTx = null;
oldTx = g2.getTransform();
g2.translate( baseX, baseY );
g2.transform( getAffineTransform( g2Transform ) );
switch ( drawMethod ) { case DRAW_STRING:
g2.drawString( line, 0, 0 ); break; case DRAW_CHARS:
g2.drawChars( line.toCharArray(), 0, line.length(), 0, 0 ); break; case DRAW_BYTES: try { byte[] lineBytes = line.getBytes(ISO_8859_1);
g2.drawBytes( lineBytes, 0, lineBytes.length, 0, 0 );
} catch ( Exception e ) {
e.printStackTrace();
} break; case DRAW_GLYPHV:
GlyphVector gv =
testFont.createGlyphVector( g2.getFontRenderContext(), line );
g2.drawGlyphVector( gv, (float) 0, (float) 0 ); break; case TL_DRAW:
TextLayout tl = new TextLayout( line, testFont,
g2.getFontRenderContext() );
tl.draw( g2, (float) 0, (float) 0 ); break; case GV_OUTLINE:
GlyphVector gvo =
testFont.createGlyphVector( g2.getFontRenderContext(), line );
g2.draw( gvo.getOutline( (float) 0, (float) 0 )); break; case TL_OUTLINE:
TextLayout tlo = new TextLayout( line, testFont,
g2.getFontRenderContext() );
AffineTransform at = new AffineTransform();
g2.draw( tlo.getOutline( at ));
}
/// ABP - restore old tform
g2.setTransform ( oldTx );
}
/// Draws one line of text at given position privatevoid tlDrawLine( Graphics2D g2, TextLayout tl, float baseX, float baseY ) { /// ABP - keep track of old tform, restore it later
AffineTransform oldTx = null;
oldTx = g2.getTransform();
g2.translate( baseX, baseY );
g2.transform( getAffineTransform( g2Transform ) );
tl.draw( g2, (float) 0, (float) 0 );
/// ABP - restore old tform
g2.setTransform ( oldTx );
}
/// If textToUse is set to range drawing, then convert /// int to hex string and prepends 0s to make it length 4 /// Otherwise line number was fed; simply return number + 1 converted to String /// (This is because first line is 1, not 0) private String modeSpecificNumStr( int i ) { if ( textToUse == USER_TEXT || textToUse == FILE_TEXT ) return String.valueOf( i + 1 );
StringBuffer s = new StringBuffer( Integer.toHexString( i )); while ( s.length() < 4 )
s.insert( 0, "0" ); return s.toString().toUpperCase();
}
/// Resets the scrollbar to display correct range of text currently on screen /// (This scrollbar is not part of a "ScrollPane". It merely simulates its effect by /// indicating the necessary area to be drawn within the panel. /// By doing this, it prevents creating gigantic panel when large text range, /// i.e. CJK Ideographs, is requested) privatevoid resetScrollbar( int oldValue ) { int totalNumRows = 1, numCharToDisplay; if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { if ( textToUse == RANGE_TEXT )
numCharToDisplay = drawRange[1] - drawRange[0]; else/// textToUse == ALL_GLYPHS
numCharToDisplay = testFont.getNumGlyphs();
/// Calculates the font's metrics that will be used for draw privatevoid calcFontMetrics( Graphics2D g2d, int w, int h ) {
FontMetrics fm;
Graphics2D g2 = (Graphics2D)g2d.create();
/// ABP if ( g2Transform != NONE && textToUse != FILE_TEXT ) {
g2.setFont( g2.getFont().deriveFont( getAffineTransform( g2Transform )) );
fm = g2.getFontMetrics();
} else {
fm = g2.getFontMetrics();
}
maxAscent = fm.getMaxAscent();
maxDescent = fm.getMaxDescent(); if (maxAscent == 0) maxAscent = 10; if (maxDescent == 0) maxDescent = 5; if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { /// Give slight extra room for each character
maxAscent += 3;
maxDescent += 3;
gridWidth = fm.getMaxAdvance() + 6;
gridHeight = maxAscent + maxDescent; if ( force16Cols )
numCharAcross = 16; else
numCharAcross = ( w - 10 ) / gridWidth;
numCharDown = ( h - 10 ) / gridHeight;
if ( !isPrinting )
resetScrollbar( verticalBar.getValue() * numCharAcross );
} else {
maxDescent += fm.getLeading();
canvasInset_X = 5;
canvasInset_Y = 5; /// gridWidth and numCharAcross will not be used in this mode...
gridHeight = maxAscent + maxDescent;
numCharDown = ( h - canvasInset_Y * 2 ) / gridHeight;
if ( numCharDown == 0 ) thrownew CannotDrawException( isPrinting ? CANT_FIT_PRINT : CANT_FIT_DRAW ); /// 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<>(); for ( int i = 0; i < fileText.length; i++ ) {
AttributedString as = new AttributedString( fileText[i], g2.getFont().getAttributes() );
LineBreakMeasurer lbm = new LineBreakMeasurer( as.getIterator(), g2.getFontRenderContext() );
while ( lbm.getPosition() < fileText[i].length() )
lineBreakTLs.add( lbm.nextLayout( (float) w ));
/// Change the status bar if not printing... if ( !isPrinting ) {
backupStatusString = ( "Displaying" + MS_OPENING[textToUse] +
modeSpecificNumStr( drawStart ) + " to " +
modeSpecificNumStr( drawEnd ) +
MS_CLOSING[textToUse] );
f2dt.fireChangeStatus( backupStatusString, false );
}
}
/// Draws text according to the parameters set by Font2DTest GUI privatevoid drawText( Graphics g, int w, int h ) {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.white);
g2.fillRect(0, 0, w, h);
g2.setColor(Color.black);
/// sets font, RenderingHints.
setParams( g2 );
/// If flag is set, recalculate fontMetrics and reset the scrollbar if ( updateFontMetrics || isPrinting ) { /// NOTE: re-calculates in case G2 transform /// is something other than NONE
calcFontMetrics( g2, w, h );
updateFontMetrics = false;
} /// Calculate the amount of text that can be drawn...
calcTextRange();
/// Draw according to the set "Text to Use" mode if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { int charToDraw = drawStart; if ( showGrid )
drawGrid( g2 );
for ( int i = 0; i < numCharDown && charToDraw <= drawEnd; i++ ) { for ( int j = 0; j < numCharAcross && charToDraw <= drawEnd; j++, charToDraw++ ) { int gridLocX = j * gridWidth + canvasInset_X; int gridLocY = i * gridHeight + canvasInset_Y;
/// Component paintComponent function... /// Draws/Refreshes canvas according to flag(s) set by other functions publicvoid paintComponent( Graphics g ) { super.paintComponent(g);
/// Printable interface function /// Component print function... publicint print( Graphics g, PageFormat pf, int pageIndex ) { if ( pageIndex == 0 ) { /// Reset the last page index to max...
lastPage = Integer.MAX_VALUE;
currentlyShownChar = verticalBar.getValue() * numCharAcross;
}
if ( printMode == ONE_PAGE ) { if ( pageIndex > 0 ) return NO_SUCH_PAGE;
} else { if ( pageIndex > lastPage ) return NO_SUCH_PAGE;
}
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<TextLayout> backupLineBreakTLs = null; if ( textToUse == FILE_TEXT )
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 ); try {
drawText( g, pageWidth, pageHeight - 60 );
} catch ( CannotDrawException e ) {
f2dt.fireChangeStatus( ERRORS[ e.id ], true ); return NO_SUCH_PAGE;
}
if ( drawEnd == drawLimit ) /// This indicates that the draw will be completed with this page
lastPage = pageIndex;
/// Restore the changed values back... /// This is important for JScrollBar settings and LineBreak'ed TLs
drawStart = backupDrawStart;
drawEnd = backupDrawEnd;
numCharAcross = backupNumCharAcross;
numCharDown = backupNumCharDown; if ( textToUse == FILE_TEXT )
lineBreakTLs = backupLineBreakTLs; return PAGE_EXISTS;
}
/// Ouputs the current canvas into a given PNG file publicvoid writePNG( String fileName ) { try { int w = this.getSize().width; int h = this.getSize().height;
BufferedImage buffer = (BufferedImage) this.createImage( w, h );
Graphics2D g2 = buffer.createGraphics();
g2.setColor(Color.white);
g2.fillRect(0, 0, w, h);
g2.setColor(Color.black);
updateFontMetrics = true;
drawText(g2, w, h);
updateFontMetrics = true;
ImageIO.write(buffer, "png", new java.io.File(fileName));
} catch ( Exception e ) {
f2dt.fireChangeStatus( "ERROR: Failed to Save PNG image; See stack trace", true );
e.printStackTrace();
}
}
/// Figures out whether a character at the pointer location is valid /// And if so, updates mouse location informations, as well as /// the information on the status bar privateboolean checkMouseLoc( MouseEvent e ) { if ( gridWidth != 0 && gridHeight != 0 ) if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { int charLocX = ( e.getX() - canvasInset_X ) / gridWidth; int charLocY = ( e.getY() - canvasInset_Y ) / gridHeight;
/// Check to make sure the mouse click location is within drawn area if ( charLocX >= 0 && charLocY >= 0 &&
charLocX < numCharAcross && charLocY < numCharDown ) { int mouseOverChar =
charLocX + ( verticalBar.getValue() + charLocY ) * numCharAcross; if ( textToUse == RANGE_TEXT )
mouseOverChar += drawRange[0]; if ( mouseOverChar > drawEnd ) returnfalse;
/// Shows (updates) the character zoom window publicvoid showZoomed() {
GlyphVector gv;
Font backup = testFont;
Point canvasLoc = this.getLocationOnScreen();
/// Calculate the zoom area's location and size... int dialogOffsetX = (int) ( gridWidth * ( ZOOM - 1 ) / 2 ); int dialogOffsetY = (int) ( gridHeight * ( ZOOM - 1 ) / 2 ); int zoomAreaX =
mouseOverCharX * gridWidth + canvasInset_X - dialogOffsetX; int zoomAreaY =
mouseOverCharY * gridHeight + canvasInset_Y - dialogOffsetY; int zoomAreaWidth = (int) ( gridWidth * ZOOM ); int zoomAreaHeight = (int) ( gridHeight * ZOOM );
/// Position and set size of zoom window as needed
zoomWindow.setLocation( canvasLoc.x + zoomAreaX, canvasLoc.y + zoomAreaY ); if ( !nowZooming ) { if ( zoomWindow.getWarningString() != null ) /// If this is not opened as a "secure" window, /// it has a banner below the zoom dialog which makes it look really BAD /// So enlarge it by a bit
zoomWindow.setSize( zoomAreaWidth + 1, zoomAreaHeight + 20 ); else
zoomWindow.setSize( zoomAreaWidth + 1, zoomAreaHeight + 1 );
}
/// Prepare zoomed image
zoomImage =
(BufferedImage) zoomWindow.createImage( zoomAreaWidth + 1,
zoomAreaHeight + 1 );
Graphics2D g2 = (Graphics2D) zoomImage.getGraphics();
testFont = testFont.deriveFont( fontSize * ZOOM );
setParams( g2 );
g2.setColor( Color.white );
g2.fillRect( 0, 0, zoomAreaWidth, zoomAreaHeight );
g2.setColor( Color.black );
g2.drawRect( 0, 0, zoomAreaWidth, zoomAreaHeight );
modeSpecificDrawChar( g2, currMouseOverChar,
zoomAreaWidth / 2, (int) ( maxAscent * ZOOM ));
g2.dispose(); if ( !nowZooming )
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...
zoomWindow.getGraphics().drawImage( zoomImage, 0, 0, this );
// Windows does not repaint correctly, after // a zoom. Thus, we need to force the canvas // to repaint, but only once. After the first repaint, // everything stabilizes. [ABP] if ( firstTime() ) {
refresh();
}
}
/// Listener Functions
/// MouseListener interface function /// Zooms a character when mouse is pressed above it publicvoid mousePressed( MouseEvent e ) { if ( !showingError) { if ( checkMouseLoc( e )) {
showZoomed(); this.setCursor( blankCursor );
}
}
}
/// MouseListener interface function /// Redraws the area that was drawn over by zoomed character publicvoid mouseReleased( MouseEvent e ) { if ( textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS ) { if ( nowZooming )
zoomWindow.setVisible(false);
nowZooming = false;
} this.setCursor( Cursor.getDefaultCursor() );
}
/// MouseListener interface function /// Resets the status bar to display range instead of a specific character publicvoid mouseExited( MouseEvent e ) { if ( !showingError && !nowZooming )
f2dt.fireChangeStatus( backupStatusString, false );
}
/// MouseMotionListener interface function /// Adjusts the status bar message when mouse moves over a character publicvoid mouseMoved( MouseEvent e ) { if ( !showingError ) { if ( !checkMouseLoc( e ))
f2dt.fireChangeStatus( backupStatusString, false );
}
}
/// MouseMotionListener interface function /// Scrolls the zoomed character when mouse is dragged publicvoid mouseDragged( MouseEvent e ) { if ( !showingError ) if ( nowZooming ) { if ( checkMouseLoc( e ) && currMouseOverChar != prevZoomChar )
showZoomed();
}
}
/// Empty function to comply with interface requirement publicvoid mouseClicked( MouseEvent e ) {} publicvoid mouseEntered( MouseEvent e ) {}
}
privatefinalclass CannotDrawException extends RuntimeException { /// Error ID publicfinalint id;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.