Class PathwayObjectEvent

java.lang.Object
org.pathvisio.libgpml.model.PathwayObjectEvent

public final class PathwayObjectEvent
extends java.lang.Object
This event is used to notify PathwayObjectListeners of changes to properties of a PathwayElement.

There are three variations on this event:

  1. Only a single, known property may have changed, that is not a coordinate change.
  2. Only one of the coordinate properties (x, y, width, height) may have changed.
  3. Any property may have changed.
Variation 2 is introduced for performance reasons. Coordinate changes generate a lot of events (e.g. resizing or dragging an object) and typically change in groups (if MLeft changes, MCenterX also changes). Listeners that are interested in coordinate changes, may filter out changes to these properties by using the isCoordinateChange() property. Listeners that are not interested in coordinate changes may use the affectsProperty(Property) method to find out if a property of interest may have changed.
Author:
Mark Woon
  • Field Details

    • pwElement

      private final PathwayObject pwElement
    • property

      private final java.lang.Object property
    • coordinateChange

      private final boolean coordinateChange
  • Constructor Details

    • PathwayObjectEvent

      private PathwayObjectEvent​(PathwayObject elem, java.lang.Object prop, boolean coordinateChange)
      Constructor.
      Parameters:
      elem - the PathwayElement that's been modified
      prop - the Property on the element that's been modified
      coordinateChange - Flag to indicate this event applies to a coordinate change.
  • Method Details

    • createSinglePropertyEvent

      protected static PathwayObjectEvent createSinglePropertyEvent​(PathwayObject pathwayObject, java.lang.Object property)
      Creates a single property event.
      Parameters:
      pathwayObject - the pathway object.
      property - the property.
      Returns:
      the pathway object event.
    • createAllPropertiesEvent

      protected static PathwayObjectEvent createAllPropertiesEvent​(PathwayObject pathwayObject)
      Creates an all properties event.
      Parameters:
      pathwayObject - the pathway object.
      Returns:
      the pathway object event.
    • createCoordinatePropertyEvent

      protected static PathwayObjectEvent createCoordinatePropertyEvent​(PathwayObject pathwayObject)
      Creates a coordinate property event.
      Parameters:
      pathwayObject - the pathway object.
      Returns:
      the pathway object event.
    • isCoordinateChange

      public boolean isCoordinateChange()
      Returns true if this event was caused by a coordinate change (e.g. movement or resize operation).
    • getModifiedPathwayObject

      public PathwayObject getModifiedPathwayObject()
      Gets the PathwayElement whose properties have been modified.
    • affectsProperty

      public boolean affectsProperty​(Property prop)
      Check if the given static property may have been modified in this event. Note that this method does not apply to coordinate properties (position, size), these need to be checked with isCoordinateChange().
      Parameters:
      prop - The property to check.
      Returns:
      true if the property may have been modified, false if not.
    • affectsProperty

      public boolean affectsProperty​(java.lang.String prop)
      Checks if the given dynamic property may have been modified in this event. Note that this method does not apply to coordinate properties (position, size), these need to be checked with isCoordinateChange().
      Parameters:
      prop - The property to check.
      Returns:
      true if the property may have been modified, false if not.