Curve with QuadCurve2D : Curve « 2D Graphics GUI « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » 2D Graphics GUI » CurveScreenshots 
Curve with QuadCurve2D
Curve with QuadCurve2D


import java.awt.Canvas;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.QuadCurve2D;
import java.awt.geom.Rectangle2D;
import java.util.Vector;

import javax.swing.JApplet;
import javax.swing.JFrame;

public class QuadCurve extends JApplet {
  DrawingCanvas canvas;

  public static void main(String[] a){
      JFrame f = new JFrame();
      QuadCurve curve = new QuadCurve();
      curve.init();
      f.getContentPane().add(curve);
      f.setDefaultCloseOperation(1);
      f.setSize(650,250);
      f.setVisible(true);
  }
  
  public void init() {
    Container container = getContentPane();
    canvas = new DrawingCanvas();
    container.add(canvas);
  }

  class DrawingCanvas extends Canvas {
    Vector quadCurves;

    QuadCurve2D selectedCurve = null;

    Rectangle2D boundingRec = null;

    public DrawingCanvas() {
      setBackground(Color.white);
      setSize(400200)// width and height of canvas

      quadCurves = new Vector();
      quadCurves.addElement(new QuadCurve2D.Float(202080160120,
          20));
      quadCurves.addElement(new QuadCurve2D.Float(12010016040200,
          180));
      quadCurves.addElement(new QuadCurve2D.Float(2402022060260,
          120));
      quadCurves.addElement(new QuadCurve2D.Float(250160260140,
          280180));
      quadCurves.addElement(new QuadCurve2D.Float(30018034040380,
          120));
      quadCurves.addElement(new QuadCurve2D.Float(2018080170120,
          190));
    }

    public void paint(Graphics g) {
      Graphics2D g2D = (Graphics2Dg;

      for (int i = 0; i < quadCurves.size(); i++) {
        g2D.draw((QuadCurve2DquadCurves.elementAt(i));
      }

    }
  }
}

           
       
Related examples in the same category
1. Move the curve control point and redraw the curve
2. Draw curve with mouseDraw curve with mouse
3. MandelbrotMandelbrot
4. A spline factory instance
ww___w__.j___av_a2s___._co___m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.