| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object
|
+--java.awt.event.MouseAdapter
|
+--ncsa.horizon.awt.color.CurveEditMode
This class is used by the CurveEditCanvas to edit its integer array data. Implementations of this abstract class support a specialized way of editing the data. This is usually based on markers that the user can create and move around by clicking on the canvas. The positions of the markers influence the values of the curve around it in some way. Whether how many markers are used is implementation-dependent.
To operate properly, this class must be given a reference to the component where the curve will be displayed and edited (e.g. the CurveEditCanvas). This is done either via a constructor or the setComponent() method. This mode will scale the plot of the data to fill up the size of the component.
Either of two abstract subclasses may be useful when implementing a specialized CurveEditMode. First, subclassing the ThreeMrkUpdEditMode is useful when the value of the curve is dependent only on the two (or at most three) surrounding Markers. The SawtoothEditMode, in which the curve is a set of line segments connecting the markers, is an example of such a implemention. The MutateEditMode can be subclassed when editing is done by tweaking a transform on the original curve data. The OffsetEditMode, in which the curve can be moved up and down, is such a mode.
| Field Summary | |
| MarkerChain | chain
|
| int[] | curvedata
|
| Marker | grabbed
|
| int | maxmarkers
|
| Constructor Summary | |
| CurveEditMode(int[] data,
int start,
int len,
int min,
int max,
java.awt.Component component,
MarkerChain markers)
initialize the mode. |
|
| CurveEditMode(int[] data,
int max,
java.awt.Component component)
initialize the mode. |
|
| CurveEditMode(int[] data,
int max,
java.awt.Component component,
MarkerChain markers)
initialize the mode. |
|
| CurveEditMode()
|
|
| Method Summary | |
| void | addActionListener(java.awt.event.ActionListener l)
set a listener to be notified when the curve has been updated. |
| void | addMarker(int x,
int y)
add a marker at the given position and update the curve accordingly. |
| java.lang.Object | clone()
clone this mode. |
| void | componentHidden(java.awt.event.ComponentEvent ev)
|
| void | componentMoved(java.awt.event.ComponentEvent ev)
|
| void | componentResized(java.awt.event.ComponentEvent ev)
|
| void | componentShown(java.awt.event.ComponentEvent ev)
|
| java.awt.Point | curveToDisplay(int x,
int y)
map a position in the curve to a position in the component where the curve will be painted. |
| java.awt.Point | curveToDisplay(java.awt.Point p)
map a position in the curve to a position in the component where the curve will be painted. |
| java.awt.Point | displayToCurve(int x,
int y)
map a position in the component where the curve is painted to an index and value in the curve array. |
| java.awt.Point | displayToCurve(java.awt.Point p)
map a position in the component where the curve is painted to an index and value in the curve array. |
| void | dragMarker(int x,
int y)
drag the currently grabbed marker to the given position and update the curve accordingly. |
| void | drawData(java.awt.Graphics g)
draw the data in the curve to the current graphics context |
| void | drawMarkers(java.awt.Graphics g)
draw the markers into a given graphics context |
| void | dropMarker(int x,
int y)
drop the currently grabbed marker. |
| int[] | getData()
return the curve array currently being edited |
| java.awt.Rectangle | getDataDomain()
return the editable domain of the array as a rectangle. |
| int | getDataEnd()
return the ending index of the interval within the curve array that is being edited. |
| int | getDataStart()
return the starting index of the interval within the curve array that is being edited. |
| MarkerChain | getMarkers()
return the collection of markers currently in use. |
| void | grabNearestMarker(int x,
int y)
grab the nearest marker to the given position |
| void | grabOrCreateMarker(int x,
int y)
grab or create a marker at the given position. |
| void | mouseDragged(java.awt.event.MouseEvent ev)
react to a mouse drag within the display component. |
| void | mouseMoved(java.awt.event.MouseEvent ev)
react to a mouse move within the display component. |
| void | mousePressed(java.awt.event.MouseEvent ev)
react to a mouse button press within the display component. |
| void | mouseReleased(java.awt.event.MouseEvent ev)
react to a mouse move within the display component. |
| void | notifyListeners()
alert listeners that the curve has been updated. |
| void | removeActionListener(java.awt.event.ActionListener l)
remove a listener |
| void | setComponent(java.awt.Component c)
set the component that will be using this mode. |
| void | setData(int[] data,
int start,
int len,
int min,
int max)
set the curve array to edit. |
| void | setData(int[] data,
java.awt.Rectangle domain)
set the curve array to edit. |
| void | setData(int[] data,
int max)
set the curve array to edit. |
| void | setMarkerChain(MarkerChain markers)
set the set of markers to be used by this mode |
| void | setMarkers(MarkerChain mc)
set the markers to be used by this mode. |
| void | snapMarkersToCurve()
move the markers vertically so as to line up with the current values in the curve array. |
| void | unsetComponent(java.awt.Component c)
unset the component using this mode. |
| void | updateCurve(int[] curvedata,
int st,
int count)
update the given array |
| void | updateCurveFor(int curvemin,
int curvemax)
update the values in the curve between the given values |
| Methods inherited from class java.awt.event.MouseAdapter | |
| mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased | |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
protected MarkerChain chain
protected int[] curvedata
protected int maxmarkers
protected Marker grabbed
| Constructor Detail |
public CurveEditMode(int[] data,
int start,
int len,
int min,
int max,
java.awt.Component component,
MarkerChain markers)
data
- the array of data to edit
start
- the first index in the array that can be edited
len
- the number of elements in the data that can be edited
min
- the minimum value an array element can have
max
- the maximum value an array element can have
component
- the component that will receive mouse events from
the user
markers
- the set of markers to use.
public CurveEditMode(int[] data,
int max,
java.awt.Component component)
data
- the array of data to edit
max
- the maximum value an array element can have
component
- the component that will receive mouse events from
the user
public CurveEditMode(int[] data,
int max,
java.awt.Component component,
MarkerChain markers)
data
- the array of data to edit
max
- the maximum value an array element can have
component
- the component that will receive mouse events from
the user
markers
- the set of markers to use.public CurveEditMode()
| Method Detail |
public void setMarkerChain(MarkerChain markers)
public void drawMarkers(java.awt.Graphics g)
public void drawData(java.awt.Graphics g)
protected void updateCurveFor(int curvemin,
int curvemax)
curvemin
- the start index of the interval to update
curvemax
- the end index of the interval to update; that is,
the index just after the last value to update.
public void addMarker(int x,
int y)
public void dragMarker(int x,
int y)
public void dropMarker(int x,
int y)
public void grabNearestMarker(int x,
int y)
public void grabOrCreateMarker(int x,
int y)
public MarkerChain getMarkers()
public void setMarkers(MarkerChain mc)
public void snapMarkersToCurve()
public int[] getData()
public int getDataStart()
public int getDataEnd()
public java.awt.Rectangle getDataDomain()
public void setData(int[] data,
int start,
int len,
int min,
int max)
data
- the array of data to edit
start
- the first index in the array that can be edited
len
- the number of elements in the data that can be edited
min
- the minimum value an array element can have
max
- the maximum value an array element can have
public void setData(int[] data,
java.awt.Rectangle domain)
data
- the array of data to edit
domain
- the domain within data that can be edited. The
input rectangle should conform to the convention
used by getDataDomain().
public void setData(int[] data,
int max)
data
- the array of data to edit
max
- the maximum value an array element can havepublic void setComponent(java.awt.Component c)
public void unsetComponent(java.awt.Component c)
protected abstract void updateCurve(int[] curvedata,
int st,
int count)
curvedata
- the data array to update
st
- the starting index to update
count
- the number of elements to update.
public java.awt.Point curveToDisplay(int x,
int y)
x
- an index in the curve array
y
- the array value at the indexpublic java.awt.Point curveToDisplay(java.awt.Point p)
p.x
- an index in the curve array
p.y
- the array value at the index
public java.awt.Point displayToCurve(int x,
int y)
x
- the x position in the component's coordinate system
y
- the y position in the component's coordinate systempublic java.awt.Point displayToCurve(java.awt.Point p)
p
- the position in the component's coordinate systempublic void mousePressed(java.awt.event.MouseEvent ev)
public void mouseDragged(java.awt.event.MouseEvent ev)
public void mouseMoved(java.awt.event.MouseEvent ev)
public void mouseReleased(java.awt.event.MouseEvent ev)
protected void notifyListeners()
public void addActionListener(java.awt.event.ActionListener l)
public void removeActionListener(java.awt.event.ActionListener l)
public void componentResized(java.awt.event.ComponentEvent ev)
public void componentMoved(java.awt.event.ComponentEvent ev)
public void componentShown(java.awt.event.ComponentEvent ev)
public void componentHidden(java.awt.event.ComponentEvent ev)
public java.lang.Object clone()
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||