|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.CDasherComponent
dasher.CDasherView
public abstract class CDasherView
Dasher views represent the visualisation of a Dasher model on the screen.
There are really three roles played by CDasherView: providing high level drawing functions, providing a mapping between Dasher co-ordinates and screen co-ordinates and providing a mapping between true and effective Dasher co-ordinates (eg for eyetracking mode).
This class supplies only those functions which are independent of the way in which we choose to represent the Model; the specifics are decided in subclasses which decide exactly how a node should be rendered. At present, the only subclass is DasherViewSquare which draws square boxes for each node.
Most actual drawing functions will be passed on to an implementation of CDasherScreen.
| Nested Class Summary | |
|---|---|
static class |
CDasherView.DPoint
|
static class |
CDasherView.DRect
Rectangle in Dasher space |
static class |
CDasherView.Point
Class representing a point on the screen. |
| Field Summary | |
|---|---|
protected int |
lpFontSize
Current font size used for drawing. |
protected long |
lpMaxY
Stores the current value of LP_MAX_Y for efficiency. |
protected boolean |
m_bVisibleRegionValid
Flag indicating whether we need to update our impression of the region in Dasher space which is currently visible. |
protected CDelayedDraw |
m_DelayDraw
Delayed drawing helper. |
protected CDasherInput |
m_Input
Current input device |
protected CDasherScreen |
m_Screen
Screen we're currently using for drawing |
protected int |
realOrientation
Stores the current value of LP_REAL_ORIENTATION again because this parameter is requested many times during drawing, which can become exceedingly inefficient. |
| Fields inherited from class dasher.CDasherComponent |
|---|
m_EventHandler, m_SettingsStore |
| Constructor Summary | |
|---|---|
CDasherView(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CDasherScreen DasherScreen)
Creates a new View wrapping a specified screen. |
|
| Method Summary | |
|---|---|
double |
applyXMapping(double x)
Applies any desired co-ordinate nonlinearity in the X direction. |
void |
ChangeScreen(CDasherScreen NewScreen)
Sets our screen. |
protected abstract void |
Crosshair(long sx)
Draws the crosshair |
abstract CDasherView.Point |
Dasher2Screen(long iDasherX,
long iDasherY)
Should convert a given Dasher co-ordinate to its equivalent screen co-ordinates. |
void |
DasherDrawCentredRectangle(long iDasherX,
long iDasherY,
int iSize,
int Color,
EColorSchemes ColorScheme,
boolean bDrawOutline)
Draws a square with a given centre in Dasher co-ordinates and a given side-length in pixels (screen co-ordinates). |
void |
DasherDrawRectangle(long iLeft,
long iTop,
long iRight,
long iBottom,
int Color,
int iOutlineColour,
EColorSchemes ColorScheme,
boolean bDrawOutline,
boolean bFill,
int iThickness)
Draws a rectangle given its top-left and bottom-right co-ordinates in Dasher space. |
long |
DasherDrawText(long iAnchorX1,
long iAnchorY1,
long iAnchorX2,
long iAnchorY2,
java.lang.String sDisplayText,
long mostleft,
boolean bShove)
Draws a given string inside a specified box, the dimensions and co-ordinates of which are given in Dasher co-ordinates. |
void |
DasherPolygon(long[] x,
long[] y,
int n,
int iColour)
Draws a filled polygon given a series of points in Dasher space. |
void |
DasherPolyline(long[] x,
long[] y,
int n,
int iWidth,
int iColour)
Draws a polyline given a series of points in Dasher space. |
void |
Display()
Deferred to our screen. |
int |
GetAutoOffset()
Stub; Returns 0 |
int |
GetCoordinateCount()
Deferred to m_Input. |
int |
GetCoordinates(int iN,
long[] Coordinates)
Deferred to m_Input |
abstract CDasherView.DPoint |
getInputDasherCoords()
Converts a pair of input co-ordinates to dasher co-ordinates. |
abstract CDasherView.DPoint |
getInputDasherCoords(java.util.ArrayList<CSymbolProb> Added)
Converts a pair of input co-ordinates to dasher co-ordinates. |
void |
HandleEvent(CEvent event)
This class responds to the following events: |
protected abstract CDasherView.DPoint |
Input2Dasher(int iInputX,
int iInputY,
int iType,
int iMode)
Converts input device co-ordinates to the appropriate, not necessarily equivalent, Dasher co-ordinates. |
boolean |
IsNodeVisible(long y1,
long y2)
Determines whether the node falling between two specified y co-ordinates is visible. |
abstract void |
NewDrawGoTo(long iDasherMin,
long iDasherMax,
boolean bActive)
Draws a square aligned to the y axis and between given y co-ordinates |
boolean |
Render(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList,
boolean bRedrawDisplay)
Renders the entire model, starting at a given Node and given specific bounds in Dasher space. |
abstract void |
RenderNodes(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
Render our nodes, beginning at a given node with given upper and lower y co-ordinates. |
void |
ResetSum()
Stub |
void |
ResetSumCounter()
Stub |
void |
ResetYAutoOffset()
Stub |
CDasherScreen |
Screen()
Gets our current screen |
abstract CDasherView.DPoint |
Screen2Dasher(int iInputX,
int iInputY,
boolean b1D,
boolean bNonlinearity)
Should convert a given screen co-ordinate to dasher co-ordinates. |
void |
SetInput(CDasherInput Input)
Sets our current reference input device and informs the new device of our maximal co-ordinates. |
void |
SpeedControl(long iDasherX,
long iDasherY,
double dFrameRate)
Applies auto speed control given the user's current input position in Dasher co-ordinates. |
abstract CDasherView.DRect |
VisibleRegion()
Returns a rectangle indicating the area in Dasher space which is current visible. |
double |
ymap(double x)
Applies any desired co-ordinate nonlinearity in the Y direction. |
| Methods inherited from class dasher.CDasherComponent |
|---|
GetBoolParameter, GetLongParameter, GetParameterName, GetParameterType, GetStringParameter, InsertEvent, SetBoolParameter, SetLongParameter, SetStringParameter, UnregisterComponent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean m_bVisibleRegionValid
protected CDasherScreen m_Screen
protected CDasherInput m_Input
protected CDelayedDraw m_DelayDraw
protected long lpMaxY
We listen for parameter change events to update this when necessary.
protected int realOrientation
protected int lpFontSize
| Constructor Detail |
|---|
public CDasherView(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CDasherScreen DasherScreen)
To this ends, the View will usually be created in response to the first call to InterfaceBase.ChangeScreen().
This constructor will also initialise fields which cache parameter values, which will subsequently be kept up to date by listening for parameter change events.
EventHandler - Event handler with which to register ourselvesSettingsStore - Settings repository to useDasherScreen - Screen object to wrap.| Method Detail |
|---|
public void HandleEvent(CEvent event)
LP_REAL_ORIENTATION, LP_MAX_Y and LP_DASHER_FONTSIZE: Updates our internally cached values of these parameters.
This method is called by the EventHandler when processing events.
HandleEvent in class CDasherComponentevent - Event to handlepublic void ChangeScreen(CDasherScreen NewScreen)
NewScreen - New screen
public boolean Render(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList,
boolean bRedrawDisplay)
At present this just passes all of its parameters to RenderNodes with the exception of bRedrawDisplay, which is ignored (the display is always redrawn).
Root - Node at which to start the drawing processiRootMin - Minimum bounding co-ordinate in Dasher spaceiRootMax - Maximum bounding co-ordinate in Dasher spacevNodeList - Collection which will be filled with Nodes which were drawnvDeleteList - Collection which will be filled with Nodes which were not drawnbRedrawDisplay - Flag indicating whether we wish for a redraw (ignored; always redraws)
public int GetCoordinateCount()
CDasherInput
public int GetCoordinates(int iN,
long[] Coordinates)
iN - Number of co-ordinatesCoordinates - Array to fill with co-ordinates
public boolean IsNodeVisible(long y1,
long y2)
Always returns true if not overridden.
y1 - upper y co-ordinatey2 - lower y co-ordinate
public void SetInput(CDasherInput Input)
The input device will not be dereferenced or deleted, as the caller may be intending for the input device to switch frequently without destroying one which is nominally out of use.
Input - New input devicepublic void Display()
CDasherScreen
public void DasherPolyline(long[] x,
long[] y,
int n,
int iWidth,
int iColour)
Internally, we convert these to screen co-ordinates and pass the request on to our screen.
Specifying a line colour of -1 causes the default to be drawn.
x - Array of points' x co-ordinatesy - Array of points' y co-ordinatesn - Number of points in the lineiWidth - Line widthiColour - Colour index (-1 means default colour)
public void DasherPolygon(long[] x,
long[] y,
int n,
int iColour)
Internally, we convert these to screen co-ordinates and pass the request on to our screen.
Specifying a colour of -1 is not handled specially by this method but ought to be translated to some sensible default by the Screen.
x - Array of points' x co-ordinatesy - Array of points' y co-ordinatesn - Number of points specifiediColour - Colour index (-1 means default colour)
public void DasherDrawRectangle(long iLeft,
long iTop,
long iRight,
long iBottom,
int Color,
int iOutlineColour,
EColorSchemes ColorScheme,
boolean bDrawOutline,
boolean bFill,
int iThickness)
The co-ordinates are translated to screen co-ordinates and the request passed on to the screen.
iLeft - Left side x co-ordinateiTop - Top y co-ordinateiRight - Right side x co-ordinateiBottom - Bottom y co-ordinateColor - Fill colouriOutlineColour - Outline colourColorScheme - Colour scheme to use (usually ignored in favour of colour indices now)bDrawOutline - Should we draw an outline?bFill - Filled?iThickness - Outline thickness
public void DasherDrawCentredRectangle(long iDasherX,
long iDasherY,
int iSize,
int Color,
EColorSchemes ColorScheme,
boolean bDrawOutline)
iDasherX - Centre point x co-ordinateiDasherY - Centre point y co-ordinateiSize - Side length in pixelsColor - Fill colour indexColorScheme - Colour scheme (usually ignored now in favour of colour index)bDrawOutline - Whether to draw a hairline black outline
public long DasherDrawText(long iAnchorX1,
long iAnchorY1,
long iAnchorX2,
long iAnchorY2,
java.lang.String sDisplayText,
long mostleft,
boolean bShove)
The actual specified bounding box is more or less taken as a guideline however, and many changes are made from that which is specified to the drawing command which is actually issued.
The most important change is that, using the mostleft parameter to indicate the right-hand edge of some ancestor's text, an effort is made to 'shove' this text to the right far enough that it does not overlap with our ancestor.
This feature is enabled only when bShove is true.
The font size to be used to draw text is currently hard coded so that text within 15 pixels of the y axis is drawn at size 11, between 15 and 30 pixels is drawn at size 14, and over 30 pixels is drawn at size 20.
The bounding box is recalculated by calling the Screen's TextSize method, which attempts to determine the dimensions of this string at a given size. This is then used to work out how far our children's text must be 'shoved' to avoid overlapping our own.
As such, this method is far from general, and should only be used to draw node labels. A new method will be required if the need arises to draw arbitrary strings in a specified location without adjustment.
This method will return a new 'mostleft' value for use when drawing our children; if the Screen's TextSize method is accurate, this ought to prevent our text from overlapping that of our children.
For the actual drawing of text, m_DelayDraw is used instead of passing the command directly to our Screen. This queue of text to draw will be emptied towards the end of the drawing cycle.
iAnchorX1 - Left edge x co-ordinateiAnchorY1 - Top edge y co-ordinateiAnchorX2 - Right edge x co-ordinateiAnchorY2 - Bottom edge y co-ordinatesDisplayText - String to drawmostleft - Co-ordinate of the right-most text drawn by our ancestor.bShove - Should we try to avoid overlapping ancestor's text?
public abstract void RenderNodes(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
Will also fill vNodeList with a list of nodes which were successfully drawn, and vDeleteList with a list of those whom we abandoned drawing because they were off screen, too small, etc.
Root - Node at which to start drawingiRootMin - Lower y co-ordinate of this nodeiRootMax - Upper y co-ordinate of this nodevNodeList - Collection to be filled with drawn nodesvDeleteList - Collection to be filled with undrawn nodespublic abstract CDasherView.DPoint getInputDasherCoords()
Also takes account of the type of input device we're using, so that one-dimensional devices and eyetrackers are corrected appropriately.
This method has been renamed from TapOnDisplay
public abstract CDasherView.DPoint getInputDasherCoords(java.util.ArrayList<CSymbolProb> Added)
Also takes account of the type of input device we're using, so that one-dimensional devices and eyetrackers are corrected appropriately.
This last parameter is redundant.
This method has been renamed from TapOnDisplay
Added - Redundant
public abstract CDasherView.DPoint Screen2Dasher(int iInputX,
int iInputY,
boolean b1D,
boolean bNonlinearity)
iInputX - Screen x co-ordinateiInputY - Screen y co-ordinateb1D - Indicates whether these co-ordinates come from a 1D devicebNonlinearity - If true, we may wish to correct for a non-linearity in one or other co-ordinate system
public abstract CDasherView.Point Dasher2Screen(long iDasherX,
long iDasherY)
iDasherX - Dasher x co-ordinateiDasherY - Dasher y co-ordinate
protected abstract CDasherView.DPoint Input2Dasher(int iInputX,
int iInputY,
int iType,
int iMode)
iInputX - Input x co-ordinateiInputY - Input y co-ordinateiType - Input co-ordinate scheme: 0 for Screen or 1 for Dasher co-ordintesiMode - Input device mode; 0 for normal, 1 for 1D and 2 for eyetracker
public int GetAutoOffset()
public abstract void NewDrawGoTo(long iDasherMin,
long iDasherMax,
boolean bActive)
iDasherMin - Bottom y co-ordinateiDasherMax - Top y co-ordinatebActive - Affects colouringpublic CDasherScreen Screen()
public void ResetSum()
public void ResetSumCounter()
public void ResetYAutoOffset()
public void SpeedControl(long iDasherX,
long iDasherY,
double dFrameRate)
iDasherX - x co-ordinateiDasherY - y co-ordinatedFrameRate - Current frame rate in FPSpublic double applyXMapping(double x)
Both input and output are co-ordinates in Dasher space.
Returns 0 in this base class; must be overridden if used.
x - raw X co-ordinate
public double ymap(double x)
Both input and output are co-ordinates in Dasher space.
Returns 0 in this base class; must be overridden if used.
x - raw Y co-ordinate
public abstract CDasherView.DRect VisibleRegion()
protected abstract void Crosshair(long sx)
sx - X co-ordinate at which to draw the crossbeam
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||