home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.lib;
-
- import sub_arctic.output.drawable;
- import sub_arctic.output.transparent_drawable;
- import sub_arctic.lib.sub_arctic_error;
-
- /**
- * This is a container class (a subclass of shrink_wrap_container) that
- * draws its child subtrees using a transparent drawable. That drawable
- * manipulates all the images drawn in it to be translucent at some
- * transparency percentage (unfortunately text, lines, etc. remain opaque).
- *
- * @author Scott Hudson
- */
- public class transparency_container extends shrink_wrap_container {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- /**
- * This constant represents the alpha value for an image which is
- * completely opaque (has no transparency factor).
- */
- public static final int OPAQUE=255;
- /**
- * This constant represents the alpha value for an image which is
- * completely transparent (and thus invisible).
- */
- public static final int TRANSPARENT=0;
- /**
- * This constant represents the alpha value for an image which is
- * 1/2 transparent and 1/2 opaque.
- */
- public static final int HALF_TRANSPARENT=127;
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Full constructor.
- * @param int xv initial x position of the container.
- * @param int yv initial y position of the container.
- * @param int alpha minimum transparency value (0 == fully transparent,
- * 255 = fully opaque). The transparency of images will
- * be set to the minimum of this and their original
- * transparency.
- */
- public transparency_container(int xv,int yv, int alpha)
- {
- super(xv,yv,0,false);
-
- if ((alpha<TRANSPARENT) ||
- (alpha>OPAQUE)) {
- throw new sub_arctic_error("Invalid alpha value: " + alpha);
- }
- _alpha_value = alpha;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor with default 50% transparency.
- * @param int xv initial x position of the container.
- * @param int yv initial y position of the container.
- */
- public transparency_container(int xv, int yv)
- {
- this(xv,yv, HALF_TRANSPARENT);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Min transparency value. 255 is fully opaque, 0 is fully transparent. */
- protected int _alpha_value;
-
- /**
- * Min transparency value. 255 is fully opaque, 0 is fully transparent.
- * @return int min transparency value.
- */
- public int alpha_value() {return _alpha_value;}
-
- /**
- * Set the min transparency value. 255 is fully opaque, 0 is fully
- * transparent.
- * @param int av new min transparency value.
- */
- public void set_alpha_value(int av)
- {
- if ((av<TRANSPARENT) ||
- (av>OPAQUE)) {
- throw new sub_arctic_error("Invalid alpha value: " + av);
- }
- _alpha_value = av;
- damage_self();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Draw self. We draw our children using special transparent_drawable.
- * @param drawable d the surface we draw on.
- */
- protected void draw_self_local(drawable d)
- {
- transparent_drawable transp_d;
-
- transp_d = new transparent_drawable(d, alpha_value());
-
- draw_children(transp_d);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
-
- /*=========================== 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/
-
- ========================================================================*/
-