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

Quick Search    Search Deep

Source code: com/memoire/dja/DjaDiamond.java


1   /**
2    * @modification $Date: 2001/12/03 16:28:08 $
3    * @statut       unstable
4    * @file         DjaDiamond.java
5    * @version      0.36
6    * @author       Guillaume Desnoix
7    * @email        guillaume@desnoix.com
8    * @license      GNU General Public License 2 (GPL2)
9    * @copyright    1998-2001 Guillaume Desnoix
10   */
11  
12  package com.memoire.dja;
13  
14  import com.memoire.fu.*;
15  import com.memoire.dnd.*;
16  import com.memoire.bu.*;
17  import com.memoire.dja.*;
18  import com.memoire.mst.*;
19  
20  
21  import java.awt.*;
22  import java.awt.event.*;
23  import javax.swing.*;
24  import javax.swing.border.*;
25  
26  public class DjaDiamond
27         extends DjaForm
28  {
29    public DjaDiamond(String _texte)
30    {
31      super(_texte);
32    }
33  
34    public DjaDiamond()
35    {
36      this(null);
37    }
38  
39    public DjaAnchor[] getAnchors()
40    {
41      int x=getX();
42      int y=getY();
43      int w=getWidth();
44      int h=getHeight();
45  
46      DjaAnchor[] r=new DjaAnchor[8];
47      r[0]=new DjaAnchor(this,0,NORTH,x+w/2,y);
48      r[2]=new DjaAnchor(this,2,EAST ,x+w-1,y+h/2);
49      r[4]=new DjaAnchor(this,4,SOUTH,x+w/2,y+h-1);
50      r[6]=new DjaAnchor(this,6,WEST ,x    ,y+h/2);
51  
52      r[1]=new DjaAnchor(this,1,NORTH,x+3*w/4,y+h/4  );
53      r[3]=new DjaAnchor(this,3,SOUTH,x+3*w/4,y+3*h/4);
54      r[5]=new DjaAnchor(this,5,SOUTH,x+w/4  ,y+3*h/4);
55      r[7]=new DjaAnchor(this,7,NORTH,x+w/4  ,y+h/4  );
56  
57      return r;
58    }
59  
60    public void paintObject(Graphics _g)
61    {
62      int x=getX();
63      int y=getY();
64      int w=getWidth();
65      int h=getHeight();
66  
67      Polygon p=new Polygon();
68      p.addPoint(x    ,y+h/2);
69      p.addPoint(x+w/2,y    );
70      p.addPoint(x+w-1,y+h/2);
71      p.addPoint(x+w/2,y+h-1);
72  
73      Color bg=getBackground();
74      if(bg!=null)
75      {
76        DjaGraphics.setColor(_g,bg);
77        DjaGraphics.fillPolygon(_g,p);
78      }
79  
80      Color fg=getForeground();
81      if(fg!=null)
82      {
83        DjaGraphics.setColor(_g,fg);
84        DjaGraphics.BresenhamParams bp=DjaGraphics.getBresenhamParams(this);
85        DjaGraphics.drawPolygon(_g,p,bp);
86      }
87  
88      super.paintObject(_g);
89    }
90  }