Package edu.cnu.mdi.container
Class CreationSupport
java.lang.Object
edu.cnu.mdi.container.CreationSupport
A utility class that provides static methods for creating various types of items (e.g., rectangles, ellipses, lines, text) from user interactions such as rubber banding or clicking.
These methods take screen coordinates and convert them to world coordinates to create the corresponding items on the specified layer.
Each created item is configured with default properties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AItemcreateEllipseItem(Layer layer, Rectangle rect) From a given screen rectangle, create an ellipse item.static AItemcreateLineItem(Layer layer, Point p0, Point p1) From two given screen points, create a line itemstatic AItemcreatePolygonItem(Layer layer, Point[] pp) From a given screen polygon, create a polygon item.static AItemcreatePolylineItem(Layer layer, Point[] pp) From a given screen polygon, create a polyline item.static AItemcreateRadArcItem(Layer layer, Point pc, Point p1, Point p2) Create a radarc item from the given parameters, probably obtained by rubberbanding.static AItemcreateRectangleItem(Layer layer, Rectangle b) From a given screen rectangle, create a rectangle item.static AItemcreateTextItem(Layer layer, Point location) Create a text item at the given screen location.static voiddefaultConfigureItem(AItem item) Configure the given item with the default interaction properties used by everycreateXxxItemfactory in this class: right-clickable, draggable, selectable, resizable, rotatable, deletable, style-editable, and unlocked.
-
Constructor Details
-
CreationSupport
public CreationSupport()
-
-
Method Details
-
createRectangleItem
From a given screen rectangle, create a rectangle item.- Parameters:
layer- the z layer to put the item onb- the screen rectangle, probably from rubber banding.- Returns:
- the new item
-
createEllipseItem
From a given screen rectangle, create an ellipse item.- Parameters:
layer- the z layer to put the item onrect- the bounding screen rectangle, probably from rubber banding.- Returns:
- the new item
-
createRadArcItem
Create a radarc item from the given parameters, probably obtained by rubberbanding.- Parameters:
layer- the z layer to put the item onpc- the center of the arcp1- the point at the end of the first leg. Thus pc->p1 determine the radius.p2- the point at the end of the second leg. Thus pc->p1->p2 determine the angle of the arc.- Returns:
- the new item
-
createTextItem
Create a text item at the given screen location.- Parameters:
layer- the z layer to put the item onlocation- the screen location- Returns:
- the new item
-
defaultConfigureItem
Configure the given item with the default interaction properties used by everycreateXxxItemfactory in this class: right-clickable, draggable, selectable, resizable, rotatable, deletable, style-editable, and unlocked.- Parameters:
item- the item to configure
-
createLineItem
From two given screen points, create a line item- Parameters:
layer- the z layer to put the item onp0- one screen point, probably from rubber banding.p1- another screen point, probably from rubber banding.- Returns:
- the new item
-
createPolygonItem
From a given screen polygon, create a polygon item.- Parameters:
layer- the z layer to put the item onpp- the screen polygon, probably from rubber banding.- Returns:
- the new item
-
createPolylineItem
From a given screen polygon, create a polyline item.- Parameters:
layer- the z layer to put the item onpp- the screen polyline, probably from rubber banding.- Returns:
- the new item
-