Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "GEF/GEF4/Geometry/Tutorial"
Line 3: | Line 3: | ||
This is a small tutorial for the GEF4 Geometry API. | This is a small tutorial for the GEF4 Geometry API. | ||
− | == | + | == 1. General behaviour == |
You can find all the shapes in the [[GEF/GEF4/Geometry#Shapes | 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 ([[GEF/GEF4/Geometry#Path |Path]]) which can be used to work with complicated composed shapes. But we will begin by demonstrating the other shapes first. | You can find all the shapes in the [[GEF/GEF4/Geometry#Shapes | 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 ([[GEF/GEF4/Geometry#Path |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: | You are able to create a shape via its constructor: | ||
Line 16: | Line 18: | ||
Line line = new Line(100, 100, 200, 200); | 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 <code>getCopy()</code> method. | ||
+ | |||
+ | Line line2 = line.getCopy(); | ||
+ | |||
+ | === Transformations === | ||
+ | |||
+ | 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 | ||
+ | * ...short-cut methods for the individual tranformations |
Revision as of 11:51, 21 October 2011
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 abstract AffineTransform class using the
shape.getTransformed(transformation)
method - ...short-cut methods for the individual tranformations