📄 toolkit.java
字号:
}public static Toolkit getDefaultToolkit () { return singleton;}public String[] getFontList () { String[] list = { "Default", "Monospaced", "SansSerif", "Serif", "Dialog", "DialogInput", "ZapfDingbats" }; return list;}public FontMetrics getFontMetrics ( Font font ) { return FontMetrics.getFontMetrics( font);}public Image getImage ( String filename ) { File f = new File( filename); // Hmm, that's a inconsistency with getImage(URL). The doc isn't very // helpful, here (class doc says nothing, book tells us it should return // null in case it's not there - but that is not known a priori for URLs). // JDK never returns a null object, so we don't do, either return (f.exists()) ? new Image( f) : Image.getUnknownImage();}public Image getImage ( URL url ) { // how can we return 'null' before we start to produce this thing (which // isn't supposed to happen here)? We are NOT going to open the URLConnection // twice just to check if it is there return new Image( url);}public int getMenuShortcutKeyMask() { return InputEvent.CTRL_MASK;}public PrintJob getPrintJob ( Frame frame, String jobtitle, Properties props ) { return new PSPrintJob( frame, jobtitle, props);}public static String getProperty ( String key, String defaultValue ) { return null;}public int getScreenResolution() { return resolution;}public Dimension getScreenSize () { return screenSize;}public Clipboard getSystemClipboard () { if ( clipboard == null ) clipboard = new NativeClipboard(); return clipboard;}public EventQueue getSystemEventQueue () { return eventQueue;}native static synchronized void graAddClip ( Pointer grData, int xClip, int yClip, int wClip, int hClip );native static synchronized void graClearRect ( Pointer grData, int x, int y, int width, int height );native static synchronized void graCopyArea ( Pointer grData, int x, int y, int width, int height, int xDelta, int yDelta );native static synchronized void graDraw3DRect ( Pointer grData, int x, int y, int width, int height, boolean raised, int rgbValue );native static synchronized void graDrawArc ( Pointer grData, int x, int y, int width, int height, int startAngle, int arcAngle );native static synchronized void graDrawBytes ( Pointer grData, byte[] data, int offset, int length, int x, int y );native static synchronized void graDrawChars ( Pointer grData, char[] data, int offset, int length, int x, int y );native static synchronized void graDrawImage( Pointer grData, Pointer imgData, int src_x, int src_y, int dst_x, int dst_y, int w, int h, int bgval );native static synchronized void graDrawImageScaled ( Pointer grData, Pointer imgData, int dx0, int dy0, int dx1, int dy1, int sx0, int sy0, int sx1, int sy1, int bgval );native static synchronized void graDrawLine ( Pointer grData, int x1, int y1, int x2, int y2 );native static synchronized void graDrawOval ( Pointer grData, int x, int y, int width, int height );native static synchronized void graDrawPolygon ( Pointer grData, int[] xPoints, int[] yPoints, int nPoints );native static synchronized void graDrawPolyline ( Pointer grData, int[] xPoints, int[] yPoints, int nPoints );native static synchronized void graDrawRect ( Pointer grData, int x, int y, int width, int height );native static synchronized void graDrawRoundRect ( Pointer grData, int x, int y, int width, int height, int arcWidth, int arcHeight );native static synchronized void graDrawString ( Pointer grData, String s, int x, int y );native static synchronized void graFill3DRect ( Pointer grData, int x, int y, int width, int height, boolean raised, int rgbValue );native static synchronized void graFillArc ( Pointer grData, int x, int y, int width, int height, int startAngle, int arcAngle );native static synchronized void graFillOval ( Pointer grData, int x, int y, int width, int height );native static synchronized void graFillPolygon ( Pointer grData, int[] xPoints, int[] yPoints, int nPoints );native static synchronized void graFillRect ( Pointer grData, int x, int y, int width, int height );native static synchronized void graFillRoundRect ( Pointer grData, int x, int y, int width, int height, int arcWidth, int arcHeight );native static synchronized void graFreeGraphics ( Pointer grData );native static synchronized Pointer graInitGraphics ( Pointer grData, Pointer tgtData, int tgtType, int xOffset, int yOffset, int xClip, int yClip, int wClip, int hClip, Pointer fontData, int fgClr, int bgClr, boolean blank );native static synchronized void graSetBackColor ( Pointer grData, int pixelValue );native static synchronized void graSetClip ( Pointer grData, int xClip, int yClip, int wClip, int hClip );native static synchronized void graSetColor ( Pointer grData, int pixelValue );native static synchronized void graSetFont ( Pointer grData, Pointer fontData );native static synchronized void graSetOffset ( Pointer grData, int xOffset, int yOffset );native static synchronized void graSetPaintMode ( Pointer grData );native static synchronized void graSetVisible ( Pointer grData, boolean isVisible );native static synchronized void graSetXORMode ( Pointer grData, int xClr );native static synchronized void imgComplete ( Pointer imgData, int status );native static synchronized Pointer imgCreateFromData( byte[] buf, int offset, int len);native static synchronized Pointer imgCreateFromFile( String gifPath);native static synchronized Pointer imgCreateImage( int w, int h);native static synchronized Pointer imgCreateScaledImage( Pointer imgData, int w, int h);native static synchronized Pointer imgCreateScreenImage( int w, int h);native static synchronized void imgFreeImage ( Pointer imgData );native static synchronized int imgGetHeight( Pointer imgData);native static synchronized int imgGetLatency ( Pointer imgData );native static synchronized Pointer imgGetNextFrame ( Pointer imgData );native static synchronized int imgGetWidth( Pointer imgData);native static synchronized boolean imgIsMultiFrame( Pointer imgData);native static synchronized void imgProduceImage( ImageNativeProducer prod, Pointer imgData);native static synchronized Pointer imgSetFrame( Pointer imgData, int frame);native static synchronized void imgSetIdxPels( Pointer imgData, int x, int y, int w, int h, int[] rgbs, byte[] pels, int trans, int off, int scans);native static synchronized void imgSetRGBPels( Pointer imgData, int x, int y, int w, int h, int[] rgbs, int off, int scans);static synchronized void initToolkit () { // this is called when the native layer has been initialized, and it is safe // to query native settings / rely on native functionality screenSize = new Dimension( tlkGetScreenWidth(), tlkGetScreenHeight()); resolution = tlkGetResolution(); // we do this here to keep the getDefaultToolkit() method as simple // as possible (since it might be called frequently). This is a // deviation from the normal Singleton (which initializes the singleton // instance upon request) singleton = new Toolkit(); eventQueue = new EventQueue();/** if ( Defaults.ConsoleClass != null ){ // since we have to defer the ConsoleWindow until the native Toolkit is propperly // initialized, it seems to be a good idea to defuse any output to the standard streams // (which might cause SEGFAULTS on some systems (e.g. DOS) System.setOut( new PrintStream( NullOutputStream.singleton)); System.setErr( System.out); }**/ if ( (flags & NATIVE_DISPATCHER_LOOP) != 0 ) { // let the world know we are ready to take over, native-wise Toolkit.class.notify(); }}protected void loadSystemColors ( int[] sysColors ) { clrSetSystemColors( sysColors);}public boolean prepareImage ( Image image, int width, int height, ImageObserver observer ) { return (Image.loadImage( image, width, height, observer));}static void redirectStreams () { try { LogClient lv = (LogClient) Class.forName( Defaults.ConsoleClass).newInstance(); LogStream ls = new LogStream( 30, lv); lv.enable(); System.setOut( new PrintStream( ls) ); System.setErr( System.out); System.out.println( "Java console enabled"); } catch ( Exception x ) { System.err.println( "unable to redirect out, err"); x.printStackTrace(); }}static synchronized void startDispatch () { if ( eventThread == null ) { eventThread = new EventDispatchThread( eventQueue); eventThread.start(); // we defer the Console creation / output redirection up to this point, since we otherwise // might get all sort of trouble because of a incompletely initialized native layer / Toolkit if ( Defaults.ConsoleClass != null ) redirectStreams(); } if ( ((flags & NEEDS_FLUSH) != 0) && (flushThread == null) ){ flushThread = new FlushThread( Defaults.GraFlushRate); flushThread.start(); }}static synchronized void stopDispatch () { if ( eventThread != null ) { eventThread.stopDispatching(); eventThread = null; } if ( flushThread != null ){ flushThread.stopFlushing(); flushThread = null; }}public void sync () { tlkSync();}static void terminate () { if ( clipboard != null ) clipboard.dispose(); stopDispatch(); tlkTerminate();} /* taken from GNU Classpath */ public DragGestureRecognizer createDragGestureRecognizer(Class recognizer, DragSource ds, Component comp, int actions, DragGestureListener l) { return null; }native static synchronized void tlkBeep ();native static synchronized void tlkDisplayBanner ( String banner );native static synchronized void tlkFlush ();native static synchronized int tlkGetResolution ();native static synchronized int tlkGetScreenHeight ();native static synchronized int tlkGetScreenWidth ();native static boolean tlkInit ( String displayName );native static synchronized int tlkProperties();native static synchronized void tlkSync ();native static synchronized void tlkTerminate ();native static synchronized String tlkVersion ();native static synchronized Pointer wndCreateDialog ( Pointer ownerData, String title, int x, int y, int width, int height, int cursorType, int bgColor, boolean isResizable );native static synchronized Pointer wndCreateFrame ( String title, int x, int y, int width, int height, int cursorType, int bgColor, boolean isResizable );native static synchronized Pointer wndCreateWindow ( Pointer ownerData, int x, int y, int width, int height, int cursorType, int bgColor );native static synchronized void wndDestroyWindow ( Pointer wndData );native static synchronized void wndRepaint ( Pointer wndData, int x, int y, int width, int height );native static synchronized void wndRequestFocus ( Pointer wndData );native static synchronized void wndSetBounds ( Pointer wndData, int x, int y, int width, int height, boolean isResizable );native static synchronized void wndSetCursor ( Pointer wndData, int cursorType );native static synchronized int wndSetDialogInsets ( int top, int left, int bottom, int right);native static synchronized int wndSetFrameInsets ( int top, int left, int bottom, int right);native static synchronized void wndSetIcon ( Pointer wndData, Pointer iconData );native static synchronized void wndSetResizable ( Pointer wndData, boolean isResizable, int x, int y, int width, int height );native static synchronized void wndSetTitle ( Pointer wndData, String title );native static synchronized void wndSetVisible ( Pointer wndData, boolean showIt );native static synchronized void wndToBack ( Pointer wndData );native static synchronized void wndToFront ( Pointer wndData );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -