Class K2DComplexElement

java.lang.Object
com.kheops.jmap.client.graphics2D.K2DElement
com.kheops.jmap.client.graphics2D.K2DComplexElement
All Implemented Interfaces:
Shareable, Serializable, Cloneable

public class K2DComplexElement extends K2DElement implements Cloneable
A class containing many K2DElement (K2DPolygon, K2DPolyline, K2DPoint, etc).
See Also:
  • Constructor Details

    • K2DComplexElement

      public K2DComplexElement()
      Constructs an empty instance of K2DComplexElement.
    • K2DComplexElement

      public K2DComplexElement(K2DElement element, long id)
      Constructs a K2DComplexElement with a Vector that contains a group of K2DElement.
      Parameters:
      element - an element to add to the complex element
      id - the id of the element
  • Method Details

    • addElement

      public void addElement(K2DElement element)
      Adds a K2DElement to the complex element.
      Parameters:
      element - the element to be added
    • addElements

      public void addElements(K2DElement[] elements)
    • removeElement

      public void removeElement(K2DElement element)
      Removes an element from this complex element.
      Parameters:
      element - the element to be removed
    • draw

      public void draw(GraphicsRef gr, K2DTransform t, Style s)
      Draws all the elements of this complex element to the specified Graphics, using the specified transform matrix and the specified style.
      Specified by:
      draw in class K2DElement
      Parameters:
      gr - the GraphicsRef object to draw on
      t - the transformation to apply to the element
      s - the style that defines the appearance of the element
      See Also:
    • clone

      public Object clone()
      Clones this complex element.
      Specified by:
      clone in class K2DElement
      Returns:
      a new instance of the drawing vector
    • sizeOf

      public int sizeOf()
      Returns the estimated memory used by this object in bytes.
      Overrides:
      sizeOf in class K2DElement
      Returns:
      the estimated memory used by this object in bytes.
    • share

      public Shareable share()
      Description copied from class: K2DElement
      Creates a clone of the current element excluding the geometry which remains the same instance in both elements.
      Use clone() to create a real copy of the current element.
      Specified by:
      share in interface Shareable
      Specified by:
      share in class K2DElement
      Returns:
      a shared instance of the current element.
      See Also:
    • drawHandles

      public void drawHandles(GraphicsRef gr, K2DTransform t, Style s)
      Description copied from class: K2DElement
      This method draws handles around the element. The position of the handles is implementation dependent. These handles are typically used to modify the geometry of the element.
      Specified by:
      drawHandles in class K2DElement
      Parameters:
      gr - the Graphics object to draw on.
      t - the transformation to apply to the element.
      s - the style of the element.
    • getDisplayBounds

      public Rectangle getDisplayBounds(K2DTransform t, Style s)
      Description copied from class: K2DElement
      Determines the bounding box of the displayed element in DC. The bounding box is the smallest possible rectangle in which the displayed element fits entirely.
      Specified by:
      getDisplayBounds in class K2DElement
      Parameters:
      t - the transformation used to calculate the display bounds of the element.
      s - the style used to calculate the display bounds of the element.
      Returns:
      the bounding box of the displayed element
    • getGeometry

      public Geometry getGeometry()
      Description copied from class: K2DElement
      Returns the geometry object associated with the element.
      Specified by:
      getGeometry in class K2DElement
      Returns:
      The geometry object associated with the element.
    • setGeometry

      public void setGeometry(Geometry geometry)
      Description copied from class: K2DElement
      Sets the geometry object associated with the element.
      Specified by:
      setGeometry in class K2DElement
      Parameters:
      geometry - the geometry
    • touches

      public boolean touches(Point dcCoord, K2DTransform t, Style s)
      Description copied from class: K2DElement
      Determines if the specified device coordinate touches the displayed element. A point touches the element if it overlaps the graphical representation of the element. The style of the element influences the result.
      Specified by:
      touches in class K2DElement
      Parameters:
      dcCoord - the device coordinate
      t - the transformation used to display the element
      s - the style used to display the element
      Returns:
      true if the element contains the point, false otherwise
      See Also:
    • getElements

      public K2DElement[] getElements()
    • setElements

      public void setElements(K2DElement[] elements)
    • getType

      public int getType()
      Description copied from class: K2DElement
      Return the current element type.
      Specified by:
      getType in class K2DElement
      Returns:
      the element type.
      See Also:
    • setSelected

      public void setSelected(boolean selected)
      Description copied from class: K2DElement
      Sets the selection state of the element.
      Overrides:
      setSelected in class K2DElement
      Parameters:
      selected - if true, the element will be selected else it will be unselected
    • getDisplayBoundsWc

      public Rectangle getDisplayBoundsWc(ViewState vs, Style s)
      Determines the bounding box including the style of element in WC (World Coordinates). The bounding box is the smallest possible rectangle in which the displayed element fits entirely. This method offers a basic implementation by transforming the DC getDisplayBounds method result in WC. To optimize performance, each K2DElement should override this method with its own implementation. See existing implementations (K2DPolygon, K2DPoint, K2DPolyline, etc.) for examples.
      Overrides:
      getDisplayBoundsWc in class K2DElement
      Parameters:
      vs - the view state that provides context information to calculate the display bounds of the element.
      s - the style used used to calculate the display bounds of the element.
      Returns:
      the bounding box of the displayed element in WC