|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.CDasherComponent
dasher.CDasherView
dasher.CDasherViewSquare
public class CDasherViewSquare
An implementation (currently the one and only) of DasherView.
This draws all DasherNodes as a square aligned to the Y axis and with sizes dependent on their probability.
The horizontal and vertical scales are both subject to non-linearity; the x axis is linear at first and logarithmic after a given point, and the y axis is linear in all places but with different decreasing magnification factors towards the edges.
| Nested Class Summary | |
|---|---|
protected class |
CDasherViewSquare.Cymap
Helper class which applies and unapplies the y-axis non-linearity. |
(package private) class |
CDasherViewSquare.D2Yret
Small class for returning dashery2screen values, which compute two new y co-ordinates and a size attribute. |
| Nested classes/interfaces inherited from class dasher.CDasherView |
|---|
CDasherView.DPoint, CDasherView.DRect, CDasherView.Point |
| Field Summary | |
|---|---|
protected int |
CanvasY
Height of our current screen in pixels |
protected long |
iLRScaleFactorX
Cached values for scaling |
protected long |
iLRScaleFactorY
Cached values for scaling |
protected long |
iTBScaleFactorX
Cached values for scaling |
protected long |
iTBScaleFactorY
Cached values for scaling |
protected int |
lpNormalisation
Cache of LP_NORAMLIZATON |
protected int |
lpTruncation
Cache of LP_TRUNCATION |
protected int |
lpTruncationType
Cache of LP_TRUNCATION_TYPE |
protected double |
m_dXMappingLinearScaleFactor
Scale factor applied to the linear portion of the x-axis nonlinearity. |
protected double |
m_dXMappingLogarithmicScaleFactor
Scale factor applied to the logarithmic portion of the x-axis nonlinearity. |
protected double |
m_dXMappingLogLinearBoundary
X co-ordinate at which we switch from linear to logarithmic magnification. |
protected CDasherView.DPoint |
m_iDasherMax
Bottom-right corner of the current visible region |
protected CDasherView.DPoint |
m_iDasherMin
Top-left corner of the current visible region |
protected long |
m_iScalingFactor
The factor that scale factors are multipled by |
protected int |
m_yAutoOffset
Nominally an offset which will be auto-calibrated and applied to input co-ordinates. |
protected CDasherViewSquare.Cymap |
m_ymap
Helper for y mapping. |
| Fields inherited from class dasher.CDasherView |
|---|
lpFontSize, lpMaxY, m_bVisibleRegionValid, m_DelayDraw, m_Input, m_Screen, realOrientation |
| Fields inherited from class dasher.CDasherComponent |
|---|
m_EventHandler, m_SettingsStore |
| Constructor Summary | |
|---|---|
CDasherViewSquare(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CDasherScreen DasherScreen)
Sole constructor. |
|
| Method Summary | |
|---|---|
double |
applyXMapping(double x)
Apply the x co-ordinate nonlinearity. |
void |
ChangeScreen(CDasherScreen NewScreen)
Sets a new screen, invalidates our current visible region, and recalls SetScalingFactor, since the relationships between Dasher and Screen co-ordinates may well have changed at this point. |
void |
Crosshair(long sx)
Draws the Crosshair, with the vertical bar at a specified x co-ordinate and the horizontal bar halfway up the screen. |
CDasherView.Point |
Dasher2Screen(long iDasherX,
long iDasherY)
Converts Dasher co-ordinates to the Screen co-ordinate indicating the same location. |
int |
GetAutoOffset()
Gets m_yAutoOffset, the y-coordinate screen offset to be applied for eyetracker devices. |
CDasherView.DPoint |
getInputDasherCoords()
Calls getInputDasherCoords(mousex, mousey, null) |
CDasherView.DPoint |
getInputDasherCoords(java.util.ArrayList<CSymbolProb> Added)
Gets the point in the Dasher world currently pointed to by our input device. |
CDasherView.DPoint |
GetScaleFactor(int eOrientation)
Retrieves the x and y scaling factors relevant to our current orientation -- so iLRScaleFactorX and Y if we're in LeftToRight or RightToLeft modes, or their TB equivalents otherwise. |
void |
HandleEvent(CEvent Event)
Method is called by the EventHandler when dispatching events. |
CDasherView.DPoint |
Input2Dasher(int iInputX,
int iInputY,
int iType,
int iMode)
Convert abstract 'input coordinates', which may or may not correspond to actual screen positions, depending on the settings, into dasher co-ordinates. |
boolean |
IsNodeVisible(long y1,
long y2)
Determines whether a node falls within our current visible region. |
void |
NewDrawGoTo(long iDasherMin,
long iDasherMax,
boolean bActive)
Draws a square highlighting the area between two given y co-ordinates. |
void |
RecursiveRender(CDasherNode Render,
long y1,
long y2,
int mostleft,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
Recursively renders a tree of Nodes beginning at a given root, based on the following procedure: |
void |
RecursiveRenderGroups(SGroupInfo CurrentGroup,
CDasherNode Node,
long y1,
long y2,
int mostleft)
Renders a given Group and all of its child groups by recursion. |
void |
RenderGroups(CDasherNode Render,
long y1,
long y2,
int mostleft)
Draws a given Node's grouping boxes, into which its Children are arranged. |
int |
RenderNode(int Color,
EColorSchemes ColorScheme,
long y1,
long y2,
int mostleft,
java.lang.String sDisplayText,
boolean bShove)
Determines whether a given Node can be drawn, and if so, draws it. |
void |
RenderNodes(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
Draws a tree of nodes beginning at a given root. |
void |
ResetYAutoOffset()
Sets m_yAutoOffset back to zero. |
CDasherView.DPoint |
Screen2Dasher(int iInputX,
int iInputY,
boolean b1D,
boolean bNonlinearity)
Convert screen co-ordinates to dasher co-ordinates. |
void |
SetScaleFactor()
Computes a set of scaling factors for use in transforming screen to Dasher co-ordinates and vice versa. |
CDasherView.Point |
TruncateToScreen(int iX,
int iY)
Truncate a set of co-ordinates so that they are on the screen |
double |
unapplyXMapping(double x)
Reverse the x co-ordinate nonlinearity. |
CDasherView.DRect |
VisibleRegion()
Produces a rectangle showing the region of Dasher space which is currently visible on screen. |
double |
ymap(double x)
Defers to m_ymap.map |
| Methods inherited from class dasher.CDasherView |
|---|
DasherDrawCentredRectangle, DasherDrawRectangle, DasherDrawText, DasherPolygon, DasherPolyline, Display, GetCoordinateCount, GetCoordinates, Render, ResetSum, ResetSumCounter, Screen, SetInput, SpeedControl |
| 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 double m_dXMappingLogarithmicScaleFactor
protected double m_dXMappingLogLinearBoundary
protected double m_dXMappingLinearScaleFactor
protected int CanvasY
protected int m_yAutoOffset
protected CDasherViewSquare.Cymap m_ymap
protected long iLRScaleFactorX
protected long iLRScaleFactorY
protected long iTBScaleFactorX
protected long iTBScaleFactorY
protected long m_iScalingFactor
protected CDasherView.DPoint m_iDasherMin
protected CDasherView.DPoint m_iDasherMax
protected int lpTruncation
protected int lpTruncationType
protected int lpNormalisation
| Constructor Detail |
|---|
public CDasherViewSquare(CEventHandler EventHandler,
CSettingsStore SettingsStore,
CDasherScreen DasherScreen)
The specific values at present are:
Multiply all linear scaled values by 0.9, switch to logarithmic scaling from the midpoint of the axis, and multiply all log scaled values by 0.2.
EventHandler - Event handler with which to register ourselvesSettingsStore - Settings repository to useDasherScreen - Screen to wrap and use for primitive drawing| Method Detail |
|---|
public void HandleEvent(CEvent Event)
This class responds to the follow parameter-change events:
LP_REAL_ORIENTATION: Invalidates our current visible region.
LP_TRUNCATION, LP_TRUNCATION_TYPE, LP_NORMALIZATION: Updates internally cached values of these parameters.
HandleEvent in class CDasherViewEvent - Event to handle
public void RenderNodes(CDasherNode Root,
long iRootMin,
long iRootMax,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
This function will call our screen's Blank method, and then call RecursiveRender on the Node we wish to draw. Once the RecursiveRender is finished, it will call m_DelayDraw's Draw method to draw all strings which have been queued up.
Finally, it will draw the Crosshair.
RenderNodes in class CDasherViewRoot - Node at which to begin drawingiRootMin - Bottom co-ordinate of the root node (in Dasher space)iRootMax - Top co-ordinate of the root node (in Dasher space)vNodeList - Collection which will be filled with drawn NodesvDeleteList - Collection which will be filled with undrawable Nodes
public void RecursiveRender(CDasherNode Render,
long y1,
long y2,
int mostleft,
java.util.Collection<CDasherNode> vNodeList,
java.util.Collection<CDasherNode> vDeleteList)
throws NodeCannotBeDrawnException
Of course, if our children are not yet present, we return after step one.
This method also takes care of filling our Collections of drawable and undrawable nodes, by catching NodeCannotBeDrawnExceptions in the latter case.
'Shoving,' the process which keeps a child node's text from overlapping that of its parent, is also co-ordinated here; the new mostleft value returned by RenderNode is passed into the recursive calls which draw our children.
Render - Node at which to begin renderingy1 - Top y co-ordinate of this Nodey2 - Bottom y co-ordinate of this Nodemostleft - Shoving parameter; see abovevNodeList - Collection to fill with drawn, childless NodesvDeleteList - Collection to fill with undrawable Nodes
NodeCannotBeDrawnException
public void RenderGroups(CDasherNode Render,
long y1,
long y2,
int mostleft)
Render - Node whose grouping boxes we wish to drawy1 - Top y co-ordinate of this Nodey2 - Bottom y co-ordinate of this Nodemostleft - Shoving parameter; indicates how far group labels should be displaced
to the right in order to avoid overlapping parents' text.
public void RecursiveRenderGroups(SGroupInfo CurrentGroup,
CDasherNode Node,
long y1,
long y2,
int mostleft)
RenderNode is used to do the actual work of drawing the group boxes, and their sizes are determined by consulting the child list which this group delimits.
CurrentGroup - Group at which to start drawingNode - Node of which this group is a childy1 - Top Dasher co-ordinate of this groupy2 - Bottom Dasher co-ordinate of this groupmostleft - Shoving parameter; indicates how far group labels should be displaced
to the right in order to avoid overlapping parents' text.
public int RenderNode(int Color,
EColorSchemes ColorScheme,
long y1,
long y2,
int mostleft,
java.lang.String sDisplayText,
boolean bShove)
throws NodeCannotBeDrawnException
If the Node is undrawable because it's off the screen or is too small to sensibly draw, a NodeCannotBeDrawnException is thrown.
The drawing instruction is clipped to the visible region first, so the Screen should not be ordered to draw anything outside its bounds.
If truncation is enabled, it is applied here; if not, we simply call DasherDrawRectangle to form the Node box.
Lastly, the Node's text is added to m_DelayDraw to be drawn to the screen at the end of the drawing sequence.
This also generates a new mostleft value for shoving purposes, which is returned to our caller.
Color - Colour index to use for the node's backgroundColorScheme - ColourScheme to use; usually ignored in favour of a colour indexy1 - Top y co-ordinate of this Node (Dasher space)y2 - Bottom y co-ordinate of this Node (Dasher space)mostleft - Shoving parameter; indicates how far node labels should be displaced
to the right in order to avoid overlapping parents' text.sDisplayText - Text to draw in this NodebShove - Should we shove (report how far our text juts out,
to help our caller avoid overlapping it)
NodeCannotBeDrawnException - if this Node cannot be drawn!
public boolean IsNodeVisible(long y1,
long y2)
IsNodeVisible in class CDasherViewy1 - Node's top y co-ordinatey2 - Node's bottom y co-ordinate
public CDasherView.DPoint Screen2Dasher(int iInputX,
int iInputY,
boolean b1D,
boolean bNonlinearity)
Screen2Dasher in class CDasherViewiInputX - Screen x co-ordinateiInputY - Screen y co-ordinateb1D - Should we use a simpler transform
for 1D devices?bNonlinearity - Should we use unapplyXMapping and m_ymap.unmap
to reverse an applied nonlinearity?
public void SetScaleFactor()
public CDasherView.DPoint GetScaleFactor(int eOrientation)
eOrientation - Current orientation
public CDasherView.Point Dasher2Screen(long iDasherX,
long iDasherY)
Applies non-linearities to the Dasher co-ordinates using applyXMapping and m_ymap.map, before scaling appropriate to our current screen orientation.
Dasher2Screen in class CDasherViewiDasherX - Dasher x co-ordinateiDasherY - Dasher y co-ordinate
public CDasherView.DRect VisibleRegion()
This is accomplished by the simple expedient of running Screen2Dasher against the minimum and maximum screen co-ordinates.
This function takes our current orientation into account in producing its answer.
VisibleRegion in class CDasherView
public CDasherView.DPoint Input2Dasher(int iInputX,
int iInputY,
int iType,
int iMode)
0 = Direct (ie mouse)
1 = 1D
2 = Eyetracker
This should be done once initially, then we work in Dasher co-ordinates for everything else. Input co-ordinates will be assumed to range over the extent of the screen.
Internally, we essentially
Input2Dasher in class CDasherViewiInputX - Input x co-ordinateiInputY - Input y co-ordinateiType - 0 if input co-ordinates are in pixels
or 1 if in Dasher co-ordinatesiMode - See table above
public CDasherView.Point TruncateToScreen(int iX,
int iY)
iX - Screen x co-ordinateiY - Screen y co-ordinate
public CDasherView.DPoint getInputDasherCoords()
getInputDasherCoords in class CDasherViewpublic CDasherView.DPoint getInputDasherCoords(java.util.ArrayList<CSymbolProb> Added)
Internally this boils down to calling GetCoordinates with the appropriate flags and then feeding the results through Input2Dasher.
getInputDasherCoords in class CDasherViewAdded - Ignored, may be null
public void NewDrawGoTo(long iDasherMin,
long iDasherMax,
boolean bActive)
Draws the square a different colour dependent on whether the 'active' flag is specified.
At present the colours are hard-coded: Colour 1 is used with a width of 3 for active, and colour 2 with a width of 1 for inactive.
NewDrawGoTo in class CDasherViewiDasherMin - Bottom y co-ordinate at which to align the squareiDasherMax - Top y co-ordinate at which to align the squarebActive - Draw this square in 'active' style?public void ResetYAutoOffset()
ResetYAutoOffset in class CDasherViewpublic void ChangeScreen(CDasherScreen NewScreen)
Also caches the Screen's current height in CanvasY.
ChangeScreen in class CDasherViewNewScreen - New screenpublic int GetAutoOffset()
GetAutoOffset in class CDasherViewpublic double ymap(double x)
ymap in class CDasherViewx - raw Y co-ordinate
CDasherViewSquare.Cymappublic void Crosshair(long sx)
The horizontal bar is hard coded to run from 12/14(sx) to 17/14(sx). This will cause trouble if sx is zero, and there will be issues if sx is small since we're working with integers, not floating point.
This method could do with being rewritten.
Crosshair in class CDasherViewsx - X co-ordinate for the vertical bar. Not zero, or
the horizontal bar will not correctly display at present.public double unapplyXMapping(double x)
For details of this non-linearity, see the constructor.
x - Value to which the mapping should be unapplied
public double applyXMapping(double x)
For details of this non-linearity, see the constructor.
applyXMapping in class CDasherViewx - Value to which the mapping should be applied
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||