Class CreationSupport

java.lang.Object
edu.cnu.mdi.container.CreationSupport

public class CreationSupport extends Object
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 Details

    • CreationSupport

      public CreationSupport()
  • Method Details

    • createRectangleItem

      public static AItem createRectangleItem(Layer layer, Rectangle b)
      From a given screen rectangle, create a rectangle item.
      Parameters:
      layer - the z layer to put the item on
      b - the screen rectangle, probably from rubber banding.
      Returns:
      the new item
    • createEllipseItem

      public static AItem createEllipseItem(Layer layer, Rectangle rect)
      From a given screen rectangle, create an ellipse item.
      Parameters:
      layer - the z layer to put the item on
      rect - the bounding screen rectangle, probably from rubber banding.
      Returns:
      the new item
    • createRadArcItem

      public static AItem createRadArcItem(Layer layer, Point pc, Point p1, Point p2)
      Create a radarc item from the given parameters, probably obtained by rubberbanding.
      Parameters:
      layer - the z layer to put the item on
      pc - the center of the arc
      p1 - 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

      public static AItem createTextItem(Layer layer, Point location)
      Create a text item at the given screen location.
      Parameters:
      layer - the z layer to put the item on
      location - the screen location
      Returns:
      the new item
    • defaultConfigureItem

      public static void defaultConfigureItem(AItem item)
      Configure the given item with the default interaction properties used by every createXxxItem factory in this class: right-clickable, draggable, selectable, resizable, rotatable, deletable, style-editable, and unlocked.
      Parameters:
      item - the item to configure
    • createLineItem

      public static AItem createLineItem(Layer layer, Point p0, Point p1)
      From two given screen points, create a line item
      Parameters:
      layer - the z layer to put the item on
      p0 - one screen point, probably from rubber banding.
      p1 - another screen point, probably from rubber banding.
      Returns:
      the new item
    • createPolygonItem

      public static AItem createPolygonItem(Layer layer, Point[] pp)
      From a given screen polygon, create a polygon item.
      Parameters:
      layer - the z layer to put the item on
      pp - the screen polygon, probably from rubber banding.
      Returns:
      the new item
    • createPolylineItem

      public static AItem createPolylineItem(Layer layer, Point[] pp)
      From a given screen polygon, create a polyline item.
      Parameters:
      layer - the z layer to put the item on
      pp - the screen polyline, probably from rubber banding.
      Returns:
      the new item