Class RGBRegion

All Implemented Interfaces:
PropertyChangeListener, EventListener, MarkingRequired, Drawable, Interactive, Measurable, Trackable

public class RGBRegion extends TTrack implements MarkingRequired
A RGBRegion measures RGB properties in a user-defined region of a video image.
Author:
Douglas Brown
  • Field Details

    • defaultEdgeLength

      protected static final int defaultEdgeLength
      See Also:
    • defaultMaxEdgeLength

      protected static final int defaultMaxEdgeLength
      See Also:
    • dataVariables

      protected static final String[] dataVariables
    • fieldVariables

      protected static final String[] fieldVariables
    • formatVariables

      protected static final String[] formatVariables
    • formatMap

      protected static final Map<String,String[]> formatMap
    • formatDescriptionMap

      protected static final Map<String,String> formatDescriptionMap
    • SHAPE_ELLIPSE

      protected static final int SHAPE_ELLIPSE
      See Also:
    • SHAPE_RECTANGLE

      protected static final int SHAPE_RECTANGLE
      See Also:
    • SHAPE_POLYGON

      protected static final int SHAPE_POLYGON
      See Also:
    • allVariables

      protected static final ArrayList<String> allVariables
    • fixedPosition

      protected boolean fixedPosition
    • fixedShape

      protected boolean fixedShape
    • fixedPositionItem

      protected JCheckBoxMenuItem fixedPositionItem
    • fixedShapeItem

      protected JCheckBoxMenuItem fixedShapeItem
    • widthLabel

      protected JLabel widthLabel
    • heightLabel

      protected JLabel heightLabel
    • helpLabel

      protected JLabel helpLabel
    • editPolygonButton

      protected TButton editPolygonButton
    • unmarkedLabel

      protected JLabel unmarkedLabel
    • maxEdgeLength

      protected int maxEdgeLength
    • shapeType

      protected int shapeType
    • shapeTypeDropdown

      protected JComboBox<String> shapeTypeDropdown
    • widthField

      protected IntegerField widthField
    • heightField

      protected IntegerField heightField
    • validSteps

      protected ArrayList<RGBStep> validSteps
    • dataHidden

      protected boolean dataHidden
    • loading

      protected boolean loading
    • shapeKeyFrames

      protected TreeSet<Integer> shapeKeyFrames
    • currentState

      protected XMLControl currentState
    • vertexHandle

      protected RGBRegion.VertexHandle vertexHandle
  • Constructor Details

    • RGBRegion

      public RGBRegion()
      Constructs a RGBRegion.
  • Method Details

    • getFormatVariables

      public String[] getFormatVariables()
      Specified by:
      getFormatVariables in class TTrack
    • getFormatMap

      public Map<String,String[]> getFormatMap()
      Specified by:
      getFormatMap in class TTrack
    • getFormatDescMap

      public Map<String,String> getFormatDescMap()
      Specified by:
      getFormatDescMap in class TTrack
    • getBaseType

      public String getBaseType()
      Specified by:
      getBaseType in class TTrack
    • getVarDimsImpl

      public String getVarDimsImpl(String variable)
      Specified by:
      getVarDimsImpl in class TTrack
    • setFixedPosition

      public void setFixedPosition(boolean fixed)
      Sets the fixed position property. When it is fixed, it is in the same position at all times.
      Overrides:
      setFixedPosition in class TTrack
      Parameters:
      fixed - true to fix the position
    • isFixedPosition

      public boolean isFixedPosition()
      Gets the fixed position property.
      Returns:
      true if image position is fixed
    • getTargetDescription

      protected String getTargetDescription(int pointIndex)
      Description copied from class: TTrack
      Returns a description of a target point with a given index.
      Overrides:
      getTargetDescription in class TTrack
      Parameters:
      pointIndex - the index
      Returns:
      the description
    • setShapeType

      protected void setShapeType(int type)
    • setFixedShape

      public void setFixedShape(boolean fixed)
      Sets the fixed shape property. When fixed, it has the same shape and size at all times.
      Parameters:
      fixed - true to fix the shape
    • isFixedShape

      public boolean isFixedShape()
      Gets the fixed shape property.
      Returns:
      true if shape and size are fixed
    • setShapeSize

      protected void setShapeSize(int n, int width, int height)
      Sets the shape size of a step and posts an undoable edit
      Parameters:
      n - the frame number
      height - the desired height
      width - the desired width
    • getShapeSize

      public Dimension getShapeSize()
      Gets the shape size.
      Returns:
      Dimension width, height
    • draw

      public void draw(DrawingPanel panel, Graphics _g)
      Overrides TTrack draw method.
      Specified by:
      draw in interface Drawable
      Overrides:
      draw in class TTrack
      Parameters:
      panel - the drawing panel requesting the drawing
      _g - the graphics context on which to draw
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Overrides TTrack findInteractive method.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class TTrack
      Parameters:
      panel - the drawing panel
      xpix - the x pixel position on the panel
      ypix - the y pixel position on the panel
      Returns:
      the first step or motion vector that is hit
    • setMarking

      protected void setMarking(boolean marking)
      Sets the marking flag. Flag should be true when ready to be marked by user.
      Overrides:
      setMarking in class TTrack
      Parameters:
      marking - true when marking
    • setTrailVisible

      public void setTrailVisible(boolean visible)
      Overrides TTrack setTrailVisible method to keep trails hidden.
      Overrides:
      setTrailVisible in class TTrack
      Parameters:
      visible - ignored
    • setLocked

      public void setLocked(boolean lock)
      Description copied from class: TTrack
      Locks and unlocks this track. When locked, no changes are allowed.
      Overrides:
      setLocked in class TTrack
      Parameters:
      lock - true to lock this
    • isAutoAdvance

      public boolean isAutoAdvance()
      Gets the autoAdvance property. Overrides TTrack method.
      Overrides:
      isAutoAdvance in class TTrack
      Returns:
      false
    • isMarkByDefault

      public boolean isMarkByDefault()
      Description copied from class: TTrack
      Gets the markByDefault property. When true, the mouse handler should mark a point whenever the active track reports itself incomplete.
      Overrides:
      isMarkByDefault in class TTrack
      Returns:
      true if this marks by default
    • requiresMarking

      public boolean requiresMarking()
      Implements MarkingRequired interface.
      Specified by:
      requiresMarking in interface MarkingRequired
    • createStep

      public Step createStep(int n, double x, double y)
      Creates a new step or moves/extends an existing one.
      Specified by:
      createStep in class TTrack
      Parameters:
      n - the frame number
      x - the x coordinate in image space
      y - the y coordinate in image space
      Returns:
      the step
    • deleteStep

      public Step deleteStep(int n)
      Overrides TTrack deleteStep method to delete polygon vertices.
      Overrides:
      deleteStep in class TTrack
      Parameters:
      n - the frame number
      Returns:
      null since step itself is not deleted
    • getStep

      public Step getStep(TPoint point, TrackerPanel trackerPanel)
      Description copied from class: TTrack
      Gets a step containing a TPoint. May return null.
      Overrides:
      getStep in class TTrack
      Parameters:
      point - a TPoint
      trackerPanel - ignored
      Returns:
      the step containing the TPoint
    • getStep

      public Step getStep(int n)
      Overrides TTrack getStep method to provide fixed behavior.
      Overrides:
      getStep in class TTrack
      Parameters:
      n - the frame number
      Returns:
      the step
    • getStepLength

      public int getStepLength()
      Gets the length of the steps created by this track.
      Specified by:
      getStepLength in class TTrack
      Returns:
      the footprint length
    • autoMarkAt

      public TPoint autoMarkAt(int n, double x, double y)
      Used by autoTracker to mark a step at a match target position.
      Overrides:
      autoMarkAt in class TTrack
      Parameters:
      n - the frame number
      x - the x target coordinate in image space
      y - the y target coordinate in image space
      Returns:
      the TPoint that was automarked
    • isAutoTrackable

      protected boolean isAutoTrackable()
      Determines if any point in this track is autotrackable.
      Overrides:
      isAutoTrackable in class TTrack
      Returns:
      true if autotrackable
    • getFootprintLength

      public int getFootprintLength()
      Gets the length of the footprints required by this track.
      Specified by:
      getFootprintLength in class TTrack
      Returns:
      the footprint length
    • clearData

      protected void clearData()
      Clears the data.
    • hideData

      protected void hideData()
      Hides the data.
    • refreshData

      protected void refreshData(DatasetManager data, TrackerPanel trackerPanel)
      Refreshes the data.
      Overrides:
      refreshData in class TTrack
      Parameters:
      data - the DatasetManager
      trackerPanel - the tracker panel
    • getMenu

      public JMenu getMenu(TrackerPanel trackerPanel, JMenu menu0)
      Overrides TTrack getMenu method.
      Overrides:
      getMenu in class TTrack
      Parameters:
      trackerPanel - the tracker panel
      menu0 - the menu. If null, a dynamic menu is returned that adds items only when selected
      Returns:
      a menu
    • getToolbarTrackComponents

      public ArrayList<Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
      Overrides TTrack getToolbarTrackComponents method.
      Overrides:
      getToolbarTrackComponents in class TTrack
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      a list of components
    • getToolbarPointComponents

      public ArrayList<Component> getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point)
      Overrides TTrack getToolbarPointComponents method.
      Overrides:
      getToolbarPointComponents in class TTrack
      Parameters:
      trackerPanel - the tracker panel
      point - the TPoint
      Returns:
      a list of components
    • setFontLevel

      public void setFontLevel(int level)
      Description copied from class: TTrack
      Sets the font level.
      Overrides:
      setFontLevel in class TTrack
      Parameters:
      level - the desired font level
    • setTrackerPanel

      public void setTrackerPanel(TrackerPanel panel)
      Adds events for TrackerPanel.
      Overrides:
      setTrackerPanel in class TTrack
      Parameters:
      panel - the new TrackerPanel
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events. This listens for the following events: "stepnumber" & "image" from TrackerPanel.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class TTrack
      Parameters:
      e - the property change event
    • toString

      public String toString()
      Overrides Object toString method.
      Overrides:
      toString in class TTrack
      Returns:
      the name of this track
    • getNumberFields

      public Map<String,NumberField[]> getNumberFields()
      Description copied from class: TTrack
      Gets a map of number fields by name.
      Overrides:
      getNumberFields in class TTrack
      Returns:
      a map of name to NumberField.
    • refreshStep

      protected void refreshStep(RGBStep step)
      Refreshes a step by setting it equal to a keyframe step.
      Parameters:
      step - the step to refresh
    • prepareVertexHandle

      protected void prepareVertexHandle(RGBStep step, int i)
    • checkPolygonEditing

      protected void checkPolygonEditing()
    • getLuma

      public static double getLuma(double r, double g, double b)
      Returns the luma (perceived brightness) of a video RGB color.
      Parameters:
      r - red component
      g - green component
      b - blue component
      Returns:
      the video luma
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an ObjectLoader to save and load data for this class.
      Returns:
      the object loader