Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "GEF/GEF4/Geometry/Tutorial"

< GEF‎ | GEF4‎ | Geometry
m
Line 28: Line 28:
 
If you want to transform a shape, there are several ways to do this. You may use...
 
If you want to transform a shape, there are several ways to do this. You may use...
  
* ...the abstract [[GEF/GEF4/Geometry#AffineTransform |AffineTransform]] class using the <code>shape.getTransformed(transformation)</code> method
+
* ...the general [[GEF/GEF4/Geometry#AffineTransform |AffineTransform]] class using the <code>shape.getTransformed(transformation)</code> method
 
* ...short-cut methods for the individual tranformations
 
* ...short-cut methods for the individual tranformations

Revision as of 07:39, 20 January 2012

Description

This is a small tutorial for the GEF4 Geometry API.

1. General behaviour

You can find all the shapes in the org.eclipse.gef4.geometry.shapes package. In the majority of cases, you will get along with those predeclared shapes. If you feel the need of another one that is not provided there, you can draw the joker (Path) which can be used to work with complicated composed shapes. But we will begin by demonstrating the other shapes first.

Shape construction

You are able to create a shape via its constructor:

   Point p1 = new Point(100, 100);
   Point p2 = new Point(200, 200);
   Line line = new Line(p1, p2);

Alternatively, every constructor is able to handle primitive data types:

   Line line = new Line(100, 100, 200, 200);
   Ellipse e = new Ellipse(100, 100, 100, 100); // x, y, w, h

Besides this constructor contract, each shape can bake a copy of its own via its getCopy() method.

   Line line2 = line.getCopy();

Transformations

If you want to transform a shape, there are several ways to do this. You may use...

  • ...the general AffineTransform class using the shape.getTransformed(transformation) method
  • ...short-cut methods for the individual tranformations

Back to the top