Area Intersect : Area Calculation « 2D Graphics GUI « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. Email
14. Event
15. File Input Output
16. Game
17. Generics
18. Hibernate
19. I18N
20. J2EE
21. J2ME
22. JDK 6
23. JSP
24. JSTL
25. Language Basics
26. Network Protocol
27. PDF RTF
28. Reflection
29. Regular Expressions
30. Scripting
31. Security
32. Servlets
33. Spring
34. Swing Components
35. Swing JFC
36. SWT JFace Eclipse
37. Threads
38. Tiny Application
39. Velocity
40. Web Services SOA
41. XML
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
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » 2D Graphics GUI » Area CalculationScreenshots 
Area Intersect
Area Intersect

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;

public class AreaIntersect extends JApplet {
    Ellipse2D.Double leaf = new Ellipse2D.Double()
    Ellipse2D.Double stem = new Ellipse2D.Double();

    Area leaf1 = new Area(leaf)
    Area leaf2 = new Area(leaf)

    public void init() {
        setBackground(Color.white);
    }

    public void paint (Graphics g) {
        Graphics2D g2 = (Graphics2Dg;
        double halfWdith = getSize().width/2;
        double halfHeight = getSize().height/2;

        g2.setColor(Color.green);

        leaf.setFrame(halfWdith-16, halfHeight-2915.015.0);
        leaf1 = new Area(leaf);
        leaf.setFrame(halfWdith-14, halfHeight-4730.030.0);
        leaf2 = new Area(leaf)
        leaf1.intersect(leaf2);   
        g2.fill(leaf1);   

    }

    public static void main(String s[]) {
        JFrame f = new JFrame("Pear");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new AreaIntersect();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(150,200));
        f.show();
    }

}


           
       
Related examples in the same category
1. Area Calculation: Add, Subtract, Intersect, Exclusive OrArea Calculation: Add, Subtract, Intersect, Exclusive Or
2. Area SubtractArea Subtract
3. Area AddArea Add
4. Area Calculation: Add, Substract, XORArea Calculation: Add, Substract, XOR
5. A Java implementation of the X11 region
w__w_w_.___j_a___v___a_2__s_.___co__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.