org.opensourcephysics.cabrillo.tracker
Class RGBRegion

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.TTrack
      extended by org.opensourcephysics.cabrillo.tracker.RGBRegion
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Drawable, Interactive, Measurable, Trackable

public class RGBRegion
extends TTrack

A RGBRegion measures RGB properties in a circular region of a video image.

Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  java.lang.String[] dataDescriptions
           
protected  boolean dataHidden
           
protected static int defaultRadius
           
protected  boolean firstTimeRadiusUnfixed
           
protected  boolean fixedPosition
           
protected  javax.swing.JCheckBoxMenuItem fixedPositionItem
           
protected  boolean fixedRadius
           
protected  javax.swing.JCheckBoxMenuItem fixedRadiusItem
           
protected  boolean loading
           
protected static int MAX_RADIUS
           
protected  IntegerField radiusField
           
protected  java.util.TreeSet<java.lang.Integer> radiusKeyFrames
           
protected  javax.swing.JLabel radiusLabel
           
protected  java.util.ArrayList<RGBStep> validSteps
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
alphabet, angleField, angleLabel, angleSeparator, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, data, dataBuilderItem, dataFrames, dataProp, dataValid, defaultColors, defaultFootprint, deleteItem, description, descriptionItem, enabled, fieldBorder, footprint, footprintListener, footprintMenu, footprints, frc, hint, isMarking, keyFrames, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, menu, name, nameAction, nameDialog, nameField, nameItem, panels, partName, point, preferredColumnOrder, properties, refreshDataLater, skippedStepWarningCheckbox, skippedStepWarningDialog, skippedStepWarningOn, skippedStepWarningTextpane, stepLabel, steps, stepSeparator, stepSizeWhenFirstMarked, stepValueLabel, support, targetIndex, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, tValueLabel, viewable, visible, visibleItem, worldBounds, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
 
Constructor Summary
RGBRegion()
          Constructs a RGBRegion.
 
Method Summary
protected  void clearData()
          Clears the data.
 Step createStep(int n, double x, double y)
          Creates a new step.
 Step deleteStep(int n)
          Overrides TTrack deleteStep method to prevent deletion.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides TTrack draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Overrides TTrack findInteractive method.
 java.lang.String getDataDescription(int index)
          Gets the description of a data variable.
 int getDefaultAutoTrackerIndex()
          Gets the default step point index.
 int getFootprintLength()
          Gets the length of the footprints required by this track.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
static double getLuma(double r, double g, double b)
          Returns the luma (perceived brightness) of a video RGB color.
 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
          Overrides TTrack getMenu method.
 int getRadius()
          Gets the radius.
 Step getStep(int n)
          Overrides TTrack getStep method to provide fixed behavior.
 int getStepLength()
          Gets the length of the steps created by this track.
 java.util.ArrayList<java.awt.Component> getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point)
          Overrides TTrack getToolbarPointComponents method.
 java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
          Overrides TTrack getToolbarTrackComponents method.
protected  void hideData()
          Hides the data.
 boolean isAutoAdvance()
          Gets the autoAdvance property.
 boolean isFixedPosition()
          Gets the fixed position property.
 boolean isFixedRadius()
          Gets the fixed radius property.
 boolean isStepComplete(int n)
          Overrides TTrack method.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshData(DatasetManager data, TrackerPanel trackerPanel)
          Refreshes the data.
protected  void refreshStep(RGBStep step)
          Refreshes a step by setting it equal to a keyframe step.
 void setFixedPosition(boolean fixed)
          Sets the fixed position property.
 void setFixedRadius(boolean fixed)
          Sets the fixed radius property.
protected  void setRadius(int n, int r)
          Sets the radius of a step and posts an undoable edit
 void setTrailVisible(boolean visible)
          Overrides TTrack setTrailVisible method to keep trails hidden.
 java.lang.String toString()
          Overrides Object toString method.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, cleanup, createWarningDialog, delete, erase, erase, firePropertyChange, getColor, getData, getDataName, getDescription, getFootprint, getFootprint, getFootprints, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getNextVisibleStep, getPreferredDataOrder, getPreviousVisibleStep, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTargetDescription, getTargetIndex, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoTrackable, isAutoTrackable, isDependent, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isStepVisible, isTrailVisible, isViewable, isVisible, refreshData, remark, remark, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAnglesInRadians, setAutoAdvance, setColor, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprint, setFootprints, setFootprints, setLocked, setMarkByDefault, setMarking, setName, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrackerPanel, setTrailLength, setViewable, setVisible, setX, setXY, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_RADIUS

protected static final int MAX_RADIUS
See Also:
Constant Field Values

defaultRadius

protected static int defaultRadius

fixedPosition

protected boolean fixedPosition

fixedRadius

protected boolean fixedRadius

fixedPositionItem

protected javax.swing.JCheckBoxMenuItem fixedPositionItem

fixedRadiusItem

protected javax.swing.JCheckBoxMenuItem fixedRadiusItem

radiusLabel

protected javax.swing.JLabel radiusLabel

radiusField

protected IntegerField radiusField

firstTimeRadiusUnfixed

protected boolean firstTimeRadiusUnfixed

validSteps

protected java.util.ArrayList<RGBStep> validSteps

dataHidden

protected boolean dataHidden

dataDescriptions

protected java.lang.String[] dataDescriptions

loading

protected boolean loading

radiusKeyFrames

protected java.util.TreeSet<java.lang.Integer> radiusKeyFrames
Constructor Detail

RGBRegion

public RGBRegion()
Constructs a RGBRegion.

Method Detail

setFixedPosition

public void setFixedPosition(boolean fixed)
Sets the fixed position property. When it is fixed, it is in the same position at all times.

Parameters:
fixed - true to fix the position

isFixedPosition

public boolean isFixedPosition()
Gets the fixed position property.

Returns:
true if image position is fixed

setFixedRadius

public void setFixedRadius(boolean fixed)
Sets the fixed radius property. When fixed, it has the same radius at all times.

Parameters:
fixed - true to fix the radius

isFixedRadius

public boolean isFixedRadius()
Gets the fixed radius property.

Returns:
true if radius is fixed

setRadius

protected void setRadius(int n,
                         int r)
Sets the radius of a step and posts an undoable edit

Parameters:
n - the frame number
r - the desired radius

getRadius

public int getRadius()
Gets the radius.

Returns:
the radius

draw

public void draw(DrawingPanel panel,
                 java.awt.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

setTrailVisible

public void setTrailVisible(boolean visible)
Overrides TTrack setTrailVisible method to keep trails hidden.

Overrides:
setTrailVisible in class TTrack
Parameters:
visible - ignored

isAutoAdvance

public boolean isAutoAdvance()
Gets the autoAdvance property. Overrides TTrack method.

Overrides:
isAutoAdvance in class TTrack
Returns:
false

isStepComplete

public boolean isStepComplete(int n)
Overrides TTrack method.

Overrides:
isStepComplete in class TTrack
Parameters:
n - the frame number
Returns:
false, so step can be moved with a shift-click

createStep

public Step createStep(int n,
                       double x,
                       double y)
Creates a new step.

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 prevent deletion.

Overrides:
deleteStep in class TTrack
Parameters:
n - the frame number
Returns:
the deleted step

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

getDefaultAutoTrackerIndex

public int getDefaultAutoTrackerIndex()
Gets the default step point index.

Specified by:
getDefaultAutoTrackerIndex in class TTrack
Returns:
the step pint index

getFootprintLength

public int getFootprintLength()
Gets the length of the footprints required by this track.

Specified by:
getFootprintLength in class TTrack
Returns:
the footprint length

getDataDescription

public java.lang.String getDataDescription(int index)
Gets the description of a data variable. Index zero is the shared x-variable, indices 1-n+1 are the y-variables.

Overrides:
getDataDescription in class TTrack
Parameters:
index - the dataset index
Returns:
a String data description

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 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
Overrides TTrack getMenu method.

Overrides:
getMenu in class TTrack
Parameters:
trackerPanel - the tracker panel
Returns:
a menu

getToolbarTrackComponents

public java.util.ArrayList<java.awt.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 java.util.ArrayList<java.awt.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

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. This listens for the following events: "stepnumber" & "image" from TrackerPanel.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class TTrack
Parameters:
e - the property change event

toString

public java.lang.String toString()
Overrides Object toString method.

Overrides:
toString in class TTrack
Returns:
the name of this track

refreshStep

protected void refreshStep(RGBStep step)
Refreshes a step by setting it equal to a keyframe step.

Parameters:
step - the step to refresh

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