Class PointItem

java.lang.Object
edu.cnu.mdi.item.AItem
edu.cnu.mdi.item.PointItem
All Implemented Interfaces:
IFeedbackProvider, IDrawable, EventListener
Direct Known Subclasses:
DeviceItem

public class PointItem extends AItem
Basic point item
Author:
heddle
  • Field Details

  • Constructor Details

    • PointItem

      public PointItem(Layer layer)
      Constructor for a basic point item.
      Parameters:
      layer - the layer this item is on.
    • PointItem

      public PointItem(Layer layer, ImageIcon icon)
      Constructor for a basic point item.
      Parameters:
      layer - the layer this item is on.
      icon - an icon to draw at the point
    • PointItem

      public PointItem(Layer layer, Point2D.Double location)
      Constructor for a basic point item.
      Parameters:
      layer - the layer this item is on.
      location - the location for the point.
    • PointItem

      public PointItem(Layer layer, Point2D.Double location, Object... keyVals)
      Constructor for a basic point item.
      Parameters:
      layer - the layer this item is on.
      location - the location for the point.
      keyVals - optional key-value pairs to set on the item. For example, you could use this to set the display name, style, or other properties at construction time. The keys should be from the set of standard keys defined in PropertyUtils, or any custom keys recognized by this item or its style.
  • Method Details

    • drawItem

      public void drawItem(Graphics2D g2, IContainer container)
      Custom drawer for the item.
      Specified by:
      drawItem in class AItem
      Parameters:
      g2 - the graphics context.
      container - the graphical container being rendered.
    • shouldDraw

      public boolean shouldDraw(Graphics2D g2, IContainer container)
      Checks whether the item should be drawn. This is an additional check, beyond the simple visibility flag check. For example, it might check whether the item intersects the area being drawn.
      Specified by:
      shouldDraw in class AItem
      Parameters:
      g2 - the graphics context.
      container - the graphical container being rendered.
      Returns:
      true if the item passes any and all tests, and should be drwan.
    • getBounds

      public Rectangle getBounds(IContainer container)
      get the bounding rect in pixels.
      Overrides:
      getBounds in class AItem
      Parameters:
      container - the container being rendered
      Returns:
      the box around the active part of the image.
    • startModification

      public void startModification()
      A modification (can only be a drag for a point item) has occurred.

      Preserves AItem.startModification()'s no-op-if-null contract, even though this override doesn't need the rotate/resize handle classification it performs.

      Overrides:
      startModification in class AItem
    • modify

      public void modify()
      A modification such as a drag, resize or rotate is continuing.
      Specified by:
      modify in class AItem
    • setFocus

      public void setFocus(Point2D.Double currentLocation)
      Set the current location.
      Overrides:
      setFocus in class AItem
      Parameters:
      currentLocation - the new location to set
    • getWorldBounds

      public Rectangle2D.Double getWorldBounds()
      Get the world bounding rectangle of the item.
      Specified by:
      getWorldBounds in class AItem
      Returns:
      the world box containing the item. For a point item, which has no extent, this is null.
    • getAlignmentH

      public int getAlignmentH()
      Get the horizontal alignment for the image icon
      Returns:
      the horizontal alignment for the image icon
    • setAlignmentH

      public void setAlignmentH(int xAlignment)
      Set the horizontal alignment for the image icon
      Parameters:
      xAlignment - the xAlignment to set
    • getAlignmentV

      public int getAlignmentV()
      Get the vertical alignment for the image icon
      Returns:
      the vertical alignment for the image icon
    • setAlignmentV

      public void setAlignmentV(int yAlignment)
      Set the vertical alignment for the image icon
      Parameters:
      yAlignment - the yAlignment to set
    • translateWorld

      public void translateWorld(double dx, double dy)
      Description copied from class: AItem
      Translate this item by (dx, dy) in world coordinates.
      Specified by:
      translateWorld in class AItem
      Parameters:
      dx - the world-coordinate offset along the X axis
      dy - the world-coordinate offset along the Y axis