Source for java.awt.peer.ComponentPeer

   1: /* ComponentPeer.java -- Toplevel component peer
   2:    Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.awt.peer;
  40: 
  41: import java.awt.AWTEvent;
  42: import java.awt.AWTException;
  43: import java.awt.BufferCapabilities;
  44: import java.awt.Color;
  45: import java.awt.Component;
  46: import java.awt.Cursor;
  47: import java.awt.Dimension;
  48: import java.awt.Font;
  49: import java.awt.FontMetrics;
  50: import java.awt.Graphics;
  51: import java.awt.GraphicsConfiguration;
  52: import java.awt.Image;
  53: import java.awt.Point;
  54: import java.awt.Toolkit;
  55: import java.awt.event.PaintEvent;
  56: import java.awt.image.ColorModel;
  57: import java.awt.image.ImageObserver;
  58: import java.awt.image.ImageProducer;
  59: import java.awt.image.VolatileImage;
  60: 
  61: public interface ComponentPeer
  62: {
  63:   int checkImage(Image img, int width, int height, 
  64:          ImageObserver ob);
  65:   Image createImage(ImageProducer prod);
  66:   Image createImage(int width, int height);
  67:   void disable();
  68:   void dispose();
  69:   void enable();
  70:   ColorModel getColorModel();
  71:   FontMetrics getFontMetrics(Font f);
  72:   Graphics getGraphics();
  73:   Point getLocationOnScreen();
  74:   Dimension getMinimumSize();
  75:   Dimension getPreferredSize();
  76:   Toolkit getToolkit();
  77:   void handleEvent(AWTEvent e);
  78:   void hide();
  79: 
  80:   /**
  81:    * Part of the earlier 1.1 API, replaced by isFocusable().
  82:    */
  83:   boolean isFocusTraversable();
  84:   boolean isFocusable();
  85:   Dimension minimumSize();
  86:   Dimension preferredSize();
  87:   void paint(Graphics graphics);
  88:   boolean prepareImage(Image img, int width, int height,
  89:                   ImageObserver ob);
  90:   void print(Graphics graphics);
  91:   void repaint(long tm, int x, int y, int width, int height);
  92: 
  93:   /**
  94:    * Part of the earlier 1.1 API, apparently replaced by argument 
  95:    * form of the same method.
  96:    */
  97:   void requestFocus();
  98:   boolean requestFocus (Component source, boolean bool1, boolean bool2, long x);
  99: 
 100:   void reshape(int x, int y, int width, int height);
 101:   void setBackground(Color color);
 102:   void setBounds(int x, int y, int width, int height);
 103: 
 104:   /**
 105:    * Part of the earlier 1.1 API, apparently no longer needed.
 106:    */
 107:   void setCursor(Cursor cursor);
 108: 
 109:   void setEnabled(boolean enabled);
 110:   void setFont(Font font);
 111:   void setForeground(Color color);
 112:   void setVisible(boolean visible);
 113:   void show();
 114: 
 115:   /** 
 116:    * Get the graphics configuration of the component. The color model
 117:    * of the component can be derived from the configuration.
 118:    */
 119:   GraphicsConfiguration getGraphicsConfiguration();
 120: 
 121:   /**
 122:    * Part of an older API, no longer needed.
 123:    */
 124:   void setEventMask (long mask);
 125: 
 126:   // Methods below are introduced since 1.1
 127:   boolean isObscured();
 128:   boolean canDetermineObscurity();
 129:   void coalescePaintEvent(PaintEvent e);
 130:   void updateCursorImmediately();
 131:   boolean handlesWheelScrolling();
 132: 
 133:   /**
 134:    * A convenience method that creates a volatile image.  The volatile
 135:    * image is created on the screen device on which this component is
 136:    * displayed, in the device's current graphics configuration.
 137:    *
 138:    * @param width width of the image
 139:    * @param height height of the image
 140:    *
 141:    * @see VolatileImage
 142:    *
 143:    * @since 1.2
 144:    */
 145:   VolatileImage createVolatileImage(int width, int height);
 146: 
 147:   /**
 148:    * Create a number of image buffers that implement a buffering
 149:    * strategy according to the given capabilities.
 150:    *
 151:    * @param numBuffers the number of buffers
 152:    * @param caps the buffering capabilities
 153:    *
 154:    * @throws AWTException if the specified buffering strategy is not
 155:    * implemented
 156:    *
 157:    * @since 1.2
 158:    */
 159:   void createBuffers(int numBuffers, BufferCapabilities caps)
 160:     throws AWTException;
 161: 
 162:   /**
 163:    * Return the back buffer of this component.
 164:    *
 165:    * @return the back buffer of this component.
 166:    *
 167:    * @since 1.2
 168:    */
 169:   Image getBackBuffer();
 170: 
 171:   /**
 172:    * Perform a page flip, leaving the contents of the back buffer in
 173:    * the specified state.
 174:    *
 175:    * @param contents the state in which to leave the back buffer
 176:    *
 177:    * @since 1.2
 178:    */
 179:   void flip(BufferCapabilities.FlipContents contents);
 180: 
 181:   /**
 182:    * Destroy the resources created by createBuffers.
 183:    *
 184:    * @since 1.2
 185:    */
 186:   void destroyBuffers();
 187: }