Trabajo Con Formas Geométricas Complejas en Java

download Trabajo Con Formas Geométricas Complejas en Java

of 2

Transcript of Trabajo Con Formas Geométricas Complejas en Java

  • 8/16/2019 Trabajo Con Formas Geométricas Complejas en Java

    1/2

    Download Ebooks

    Download JDK  Search Java Tutorials  Hide TOC

    Home Page > 2D Graphics > Advanced Topics in Java2Dvanced Topics in Java2D

    ransforming Shapes,

    Text, and Images

    lipping the Drawing

    Region

    ompositing Graphics

    ontrolling Rendering

    Quality

    onstructing Complex

    Shapes from Geometry

    Primitives

    upporting User 

    nteraction

    « Previous • Trail • Next »

    Constructing Complex Shapes from Geometry Primitives

    Constructive area geometry (CAG) is the process of creating new geometric shapes by performing boolean operations on existing ones. In the Java 2D

     API the Area class implements the Shape interface and supports the following boolean operations.

    Union Subtraction

    Intersection Exclusive-or (XOR)

    Example: Areas

    In this example Area objects construct a pear shape from several ellipses.

    Note:  If you don't see the applet running, you need to install at least the Java SE Development Kit (JDK) 7 release.

    Pear.java contains the complete code for this applet.

    The leaves are each created by performing an intersection on two overlapping circles.

    leaf = new Ellipse2D.Double();

    ...

    leaf1 = new Area(leaf);

    leaf2 = new Area(leaf);

    ...

    leaf.setFrame(ew-16, eh-29, 15.0, 15.0);

    leaf1 = new Area(leaf);

    leaf.setFrame(ew-14, eh-47, 30.0, 30.0);

    leaf2 = new Area(leaf);

    leaf1.intersect(leaf2);

    g2.fill(leaf1);

    ...

    leaf.setFrame(ew+1, eh-29, 15.0, 15.0);

    leaf1 = new Area(leaf);

    leaf2.intersect(leaf1);

    g2.fill(leaf2);

    Overlapping circles are also used to construct the stem through a subtraction operation.

    stem = new Ellipse2D.Double();

    ...

    stem.setFrame(ew, eh-42, 40.0, 40.0);

    st1 = new Area(stem);

    stem.setFrame(ew+3, eh-47, 50.0, 50.0);

    st2 = new Area(stem);

    st1.subtract(st2);

    g2.fill(st1);

    The body of the pear is constructed by performing a union operation on a circle and an oval.

    circle = new Ellipse2D.Double();

    oval = new Ellipse2D.Double();

    circ = new Area(circle);

    ov = new Area(oval);

    ...

    circle.setFrame(ew-25, eh, 50.0, 50.0);

    oval.setFrame(ew-19, eh-20, 40.0, 70.0);

    circ = new Area(circle);

    ov = new Area(oval);

    circ.add(ov);

    g2.fill(circ);

    « Previous • Trail • Next »

    our use of this page and all the material on pages under "The Java Tutorials" banner is subject to these legal notices.

    opyright © 1995, 2015 Oracle and/or its affiliates. Al l rights reserved.

    Problems with the examples? Try Compiling and Running the Examples: FAQs.

    Complaints? Compliments? Suggestions? Give us your feedback.

    Documentation

    The Java™ Tutorials

     

    http://docs.oracle.com/javase/tutorial/search.htmlhttp://docs.oracle.com/javase/tutorial/information/cpyr.htmlhttps://docs.oracle.com/javase/feedback.htmlhttp://docs.oracle.com/javase/tutorial/information/run-examples.htmlhttp://docs.oracle.com/javase/tutorial/information/cpyr.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/user.htmlhttp://docs.oracle.com/javase/tutorial/2d/TOC.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/quality.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/examples/Pear.javahttp://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttps://docs.oracle.com/javase/8/docs/api/java/awt/Shape.htmlhttps://docs.oracle.com/javase/8/docs/api/java/awt/geom/Area.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/user.htmlhttp://docs.oracle.com/javase/tutorial/2d/TOC.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/quality.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/index.htmlhttp://docs.oracle.com/javase/tutorial/2d/index.htmlhttp://docs.oracle.com/javase/tutorial/index.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/user.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/quality.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/compositing.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/clipping.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/transforming.htmlhttp://docs.oracle.com/javase/tutorial/2d/advanced/index.htmlhttp://toggleleft%28%29/http://docs.oracle.com/javase/tutorial/search.htmlhttp://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://www.oracle.com/technetwork/java/javase/downloads/java-se-7-tutorial-2012-02-28-1536013.html

  • 8/16/2019 Trabajo Con Formas Geométricas Complejas en Java

    2/2