home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.lib;
-
- import sub_arctic.output.loaded_image;
- import sub_arctic.output.drawable;
- import java.awt.Image;
-
- /**
- * This object simply displays an image on the screen. It has no input
- * behavior... if you want input behavior, subclass this and implement one
- * of the input protocols, such as clickable or pressable. <p>
- *
- * If you supply a null image, you will get a 10 x 10 blank rectangle
- * when you try to display the icon.
-
- * @author Scott Hudson
- */
- public class icon extends base_interactor {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Full constructor for an icon.
- * @param int x the x coordinate of the icon
- * @param int y the y coordinate of the icon
- * @param loaded_image img the image to display (if you pass null for the
- * image you get a 10x10 blank square).
- */
- public icon(int x, int y, loaded_image img)
- {
- super(x,y);
-
- /* save instance variable */
- _image = img;
-
- /* set it so we get intrinsic w & h set up */
- set_image(img);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Simple constructor for an icon. This assumes you are going to
- * either explicitly set the position or use constraints to position
- * this object.
- *
- * @param loaded_image img the image to display (if you pass null for the
- * image you get a 10x10 blank square).
- */
- public icon(loaded_image img)
- {
- super(0,0);
-
- /* save instance variable */
- _image = img;
-
- /* set it so we get intrinsic w & h set up */
- set_image(img);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Image for the icon. */
- protected loaded_image _image;
-
- /**
- * Image for the icon.
- * @return loaded_image return the current image for this icon
- */
- public loaded_image image() {return _image; }
-
- /**
- * Set the image to use for this icon
- *
- * @param loaded_image img the new image to use
- */
- public void set_image(loaded_image img) {
- _image = img;
-
- /* if it doesn't have a size yet, just make it 10x10 */
- if (_image==null) {
- set_intrinsic_size(10,10);
- } else {
- /* set correct initial size */
- set_intrinsic_size(_image.width(), _image.height());
- }
- damage_self();
- }
-
- //had
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Draw the icon.
- * @param drawable d the drawable to render this object on
- */
- protected void draw_self_local(drawable d)
- {
- if (_image==null) {
- d.clearRect(0,0,w(),h());
- d.drawRect(0,0,w()-1,h()-1);
- } else {
- d.drawImage(_image,0,0);
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate that we intrinsically constrain both height & width.
- * Thus, it is not modifiable by either the programmer or user.
- * @return int return the constant indicating the correct intrinsic dimensions
- */
- public int intrinsic_constraints() {
- return H | W;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-