Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved. |
| 3 | // |
| 4 | // This is free software; you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation; either version 2 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This software is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this software; if not, write to the Free Software |
| 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | // USA. |
| 18 | // |
| 19 | |
Adam Tkac | f53e62a | 2009-03-13 13:20:26 +0000 | [diff] [blame] | 20 | package com.tigervnc.vncviewer; |
Constantin Kaplinsky | 90d8a50 | 2008-04-14 09:45:50 +0000 | [diff] [blame] | 21 | |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 22 | import java.awt.*; |
| 23 | import java.io.*; |
| 24 | |
| 25 | // |
| 26 | // VncCanvas2 is a special version of VncCanvas which may use Java 2 API. |
| 27 | // |
| 28 | |
| 29 | class VncCanvas2 extends VncCanvas { |
| 30 | |
| 31 | public VncCanvas2(VncViewer v) throws IOException { |
| 32 | super(v); |
| 33 | disableFocusTraversalKeys(); |
| 34 | } |
| 35 | |
| 36 | public VncCanvas2(VncViewer v, int maxWidth_, int maxHeight_) |
| 37 | throws IOException { |
| 38 | |
| 39 | super(v, maxWidth_, maxHeight_); |
| 40 | disableFocusTraversalKeys(); |
| 41 | } |
| 42 | |
| 43 | public void paintScaledFrameBuffer(Graphics g) { |
| 44 | Graphics2D g2d = (Graphics2D)g; |
| 45 | g2d.setRenderingHint(RenderingHints.KEY_RENDERING, |
| 46 | RenderingHints.VALUE_RENDER_QUALITY); |
| 47 | g2d.drawImage(memImage, 0, 0, scaledWidth, scaledHeight, null); |
| 48 | } |
| 49 | |
| 50 | // |
| 51 | // Try to disable focus traversal keys (JVMs 1.4 and higher). |
| 52 | // |
| 53 | |
| 54 | private void disableFocusTraversalKeys() { |
| 55 | try { |
| 56 | Class[] argClasses = { Boolean.TYPE }; |
| 57 | java.lang.reflect.Method method = |
| 58 | getClass().getMethod("setFocusTraversalKeysEnabled", argClasses); |
| 59 | Object[] argObjects = { new Boolean(false) }; |
| 60 | method.invoke(this, argObjects); |
| 61 | } catch (Exception e) {} |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | |