Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/xerox/VTM/glyphs/VEllipseST.java


1   /*   FILE: VEllipseST.java
2    *   DATE OF CREATION:   Dec 24 2001
3    *   AUTHOR :            Emmanuel Pietriga (emmanuel.pietriga@xrce.xerox.com)
4    *   MODIF:              Thu Jul 10 16:44:46 2003 by Emmanuel Pietriga (emmanuel@w3.org, emmanuel@claribole.net)
5    *   Copyright (c) Xerox Corporation, XRCE/Contextual Computing, 2002. All Rights Reserved
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   * 
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * For full terms see the file COPYING.
18   */
19  
20  package com.xerox.VTM.glyphs;
21  
22  import java.lang.Math;
23  import java.awt.Color;
24  import java.awt.Graphics2D;
25  import java.awt.Font;
26  import java.awt.Shape;
27  import java.awt.Stroke;
28  import java.awt.AlphaComposite;
29  import java.awt.geom.*;
30  import java.util.Vector;
31  import com.xerox.VTM.engine.*;
32  
33    /**
34     * Ellipse - cannot be reoriented - transparency
35     * @author Emmanuel Pietriga
36     */
37  
38  public class VEllipseST extends VEllipse implements Transparent,Cloneable {
39  
40      /**semi transparency (default is 0.5)*/
41      AlphaComposite acST;
42      /**alpha channel*/
43      float alpha=0.5f;
44  
45      public VEllipseST(){
46    super();
47    acST=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,alpha);  //transparency set to 0.5
48      }
49  
50      /**
51       *@param x coordinate in virtual space
52       *@param y coordinate in virtual space
53       *@param z altitude
54       *@param w half width in virtual space
55       *@param h half height in virtual space
56       *@param c fill color
57       */
58      public VEllipseST(long x,long y,float z,long w,long h,Color c){
59    super(x,y,z,w,h,c);
60    acST=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,alpha);  //transparency set to 0.5
61      }
62  
63      /**
64       *set alpha channel value (transparency)
65       *@param a [0;1.0] 0 is fully transparent, 1 is opaque
66       */
67      public void setTransparencyValue(float a){
68    alpha=a;
69    acST=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,alpha);  //transparency set to alpha
70    try{vsm.repaintNow();}catch(NullPointerException e){/*System.err.println("VSM null in Glyph "+e);*/}
71      }
72  
73      /**get alpha value (transparency) for this glyph*/
74      public float getTransparencyValue(){return alpha;}
75  
76      /**draw glyph 
77       *@param i camera index in the virtual space
78       */
79      public void draw(Graphics2D g,int vW,int vH,int i,Stroke stdS,AffineTransform stdT){
80    if ((pc[i].ellipse.getBounds().width>2) && (pc[i].ellipse.getBounds().height>2)){
81        if (filled){
82      g.setColor(this.color);
83      g.setComposite(acST);
84      g.fill(pc[i].ellipse);
85      g.setComposite(acO);
86        }
87        g.setColor(borderColor);
88        if (paintBorder){
89      if (stroke!=null){
90          g.setStroke(stroke);
91          g.draw(pc[i].ellipse);
92          g.setStroke(stdS);
93      }
94      else {
95          g.draw(pc[i].ellipse);
96      }
97        }   
98        this.textDraw(g,i);
99    }
100   else g.fillRect(pc[i].cx,pc[i].cy,1,1);
101     }
102 
103     /**returns a clone of this object (only basic information is cloned for now: shape, orientation, position, size)*/
104     public Object clone(){
105   VEllipseST res=new VEllipseST(vx,vy,0,vw,vh,color);
106   res.borderColor=this.borderColor;
107   res.selectedColor=this.selectedColor;
108   res.mouseInsideColor=this.mouseInsideColor;
109   res.bColor=this.bColor;
110   res.setTransparencyValue(alpha);
111   return res;
112     }
113 
114 }