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

Quick Search    Search Deep

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


1   /**
2    * @modification $Date: 2002/07/26 09:39:31 $
3    * @statut       unstable
4    * @file         DjaGraphics2.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.bu.*;
16  import com.memoire.dja.*;
17  
18  import java.awt.*;
19  
20  /**
21   * Independant graphics ops (1.2 implementation).
22   */
23  public class DjaGraphics2
24    extends DjaGraphics0
25  {
26    public static Stroke getStroke(DjaGraphics.BresenhamParams _bp)
27    {
28      float e=(float)_bp.epaisseur_;
29      float[] dash=null;
30      if(_bp.vide_>0)
31        dash=new float[] { (float)_bp.trait_,
32         e*(float)_bp.vide_+2.f };
33      
34      return new BasicStroke
35        (e,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_MITER,
36         2.f*e,dash,0.f);
37    }
38  
39    public void drawLine
40      (Graphics _g, int _x1, int _y1, int _x2, int _y2, DjaGraphics.BresenhamParams _bp)
41    {
42      Graphics2D g2d=(Graphics2D)_g;
43      Stroke old=g2d.getStroke();
44      g2d.setStroke(getStroke(_bp));
45      g2d.drawLine(_x1,_y1,_x2,_y2);
46      g2d.setStroke(old);
47    }
48  
49    public void drawRect
50      (Graphics _g, int _x, int _y, int _w, int _h, DjaGraphics.BresenhamParams _bp)
51    {
52      Graphics2D g2d=(Graphics2D)_g;
53      Stroke old=g2d.getStroke();
54      g2d.setStroke(getStroke(_bp));
55      g2d.drawRect(_x,_y,_w,_h);
56      g2d.setStroke(old);
57    }
58  
59    public void drawRoundRect
60      (Graphics _g, int _x, int _y, int _w, int _h,
61       int _rh, int _rv, DjaGraphics.BresenhamParams _bp)
62    {
63      Graphics2D g2d=(Graphics2D)_g;
64      Stroke old=g2d.getStroke();
65      g2d.setStroke(getStroke(_bp));
66      g2d.drawRoundRect(_x,_y,_w,_h,_rh,_rv);
67      g2d.setStroke(old);
68    }
69  
70    public void fillRoundRect
71      (Graphics _g, int _x, int _y, int _w, int _h,
72       int _rh, int _rv)
73    {
74      _g.fillRoundRect(_x,_y,_w,_h,_rh,_rv);
75    }
76  
77    public void drawOval
78      (Graphics _g, int _x, int _y, int _w, int _h, DjaGraphics.BresenhamParams _bp)
79    {
80      Graphics2D g2d=(Graphics2D)_g;
81      Stroke old=g2d.getStroke();
82      g2d.setStroke(getStroke(_bp));
83      g2d.drawOval(_x,_y,_w,_h);
84      g2d.setStroke(old);
85    }
86  
87    public void fillOval
88      (Graphics _g, int _x, int _y, int _w, int _h)
89    {
90      _g.fillOval(_x,_y,_w,_h);
91    }
92  
93    public void drawPolyline
94      (Graphics _g, int[] _xpoints, int[] _ypoints, int _npoints,
95       DjaGraphics.BresenhamParams _bp)
96    {
97      Graphics2D g2d=(Graphics2D)_g;
98      Stroke old=g2d.getStroke();
99      g2d.setStroke(getStroke(_bp));
100     g2d.drawPolyline(_xpoints,_ypoints,_npoints);
101     g2d.setStroke(old);
102   }
103 
104   public void drawPolygon
105     (Graphics _g, int[] _xpoints, int[] _ypoints, int _npoints,
106      DjaGraphics.BresenhamParams _bp)
107   {
108     Graphics2D g2d=(Graphics2D)_g;
109     Stroke old=g2d.getStroke();
110     g2d.setStroke(getStroke(_bp));
111     g2d.drawPolygon(_xpoints,_ypoints,_npoints);
112     g2d.setStroke(old);
113   }
114 }