|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.net.NetScreen
public class NetScreen
Specialised implementation of CDasherScreen which, instead of drawing its output to the screen, produces an XML document describing drawing primitives.
The XML is then serialized and output to a specified OutputStream (in the context of NetDasher typically a Socket's OutputStream) with the intent that some client application should render the drawing primitives described by the document and so reproduce the display.
The class also currently plays the role of injecting XML tags informing the client of EditEvents and of delivering some extra data in the first frame sent to a given client. In the future, these roles should ideally be moved into a seperate class such that the different classes which want to deliver XML to the client could each create an Element, and combination and serialization could be co-ordinated by some master NetDasherOutput class.
XML format
The entire document is always surrounded by
tags....
init: Sent only with the first produced frame, to notify the client of initial conditions. Contains the following children:
sessid: Contains the session ID associated with this newly created Dasher.
alphabet: An <alphabet/> tag is included for each alphabet Dasher knows about. The title of each is described in the tag's name attribute, and the default attribute will be 'true' for one alphabet, indicating that which Dasher is using by default. Example: %lt;alphabet name="French" default="true"/>
colour: A <colour/> tag is included for each colour scheme Dasher knows about. The title of each is described in the tag's name attribute, and the default attribute will be 'true' for one alphabet, indicating that which Dasher is using by default. Example: <colour name="Rainbow" default="true"/>
edit: Records every EditEvent which has been received by this Screen since the last frame.
The children of edit are of the form:
add: Add tags surround text added since the last frame; the tags are recorded in the XML document in the same order as the events occured. Example: <add>H</add>
remove: Have a single attribute named 'num' which indicates how many characters have been deleted. Example: <remove num="3"/>
frame: Frame tags contain a sequence of tags describing drawing primitives. The tags which may occur here are each described in the documentation for the function which may produce them, below.
| Field Summary | |
|---|---|
protected java.util.ArrayList<java.lang.String> |
Alphabets
List of available alphabets |
protected java.util.ArrayList<java.lang.String> |
Colours
List of available colour schemes |
protected org.w3c.dom.Document |
drawInstructions
Document object which should be populated with data to be sent and which will in due time be serialized to our OutputStream. |
protected java.util.Queue<CEditEvent> |
editEventQueue
Queue of EditEvents registered since the last frame was drawn. |
protected boolean |
firstMessage
Flag indicating whether to output an init section with our next frame. |
protected org.w3c.dom.Element |
frame
Element to which all drawing primitives should be attached. |
protected java.lang.String |
initialAlph
Default alphabet name |
protected java.lang.String |
initialCS
Default colour scheme |
protected CCustomColours |
m_ColourScheme
Colour scheme currently in use |
protected int |
m_Height
Height of this screen in pixels |
protected java.io.OutputStream |
m_Output
OutputStream to which XML should be serialized at the end of the drawing cycle. |
protected int |
m_Width
Width of this screen in pixels |
protected javax.xml.parsers.DocumentBuilder |
parser
DocumentBuilder to be used in producing XML |
protected org.w3c.dom.Element |
root
Element from which all other elements descend; named 'message' in the document schema. |
protected int |
sessID
Session ID associated with the Dasher to which this Screen is linked. |
protected javax.xml.transform.Transformer |
XMLSerializer
Transformer which will render the XML document as text prior to output. |
| Constructor Summary | |
|---|---|
NetScreen(int sessID,
int width,
int height)
Creates a new NetScreen. |
|
| Method Summary | |
|---|---|
void |
addEditEvent(CEditEvent event)
Records an EditEvent to be added to the XML document during a call to Display(). |
protected void |
addEditEvents()
Adds all EditEvents recorded since the last frame to the XML document, in the manner described in the class summary. |
void |
Blank()
Signals the start of a new frame; see CDasherScreen for the general contract of this method. |
void |
Display()
Calls addEditEvents before serializing the XML document produced during the drawing cycle and writing it to m_Output, (an OutputStream specified by the setOutput method). |
void |
DrawCircle(int iCX,
int iCY,
int iR,
int iColour,
boolean bFill)
Adds a tag of the form <circle centrex="..." centrey="..." radius="..." fill="..." colour="..."/> to the Frame tag of this document. |
void |
DrawRectangle(int x1,
int y1,
int x2,
int y2,
int Color,
int iOutlineColour,
EColorSchemes ColorScheme,
boolean bDrawOutline,
boolean bFill,
int iThickness)
Adds a tag of the form <rect x="..." y="..." w="..." h="..." colour="..." olcolour="..." thickness="..." fill="..." drawoutline="..."/> to the Frame tag of this document. |
void |
DrawString(java.lang.String string,
int x1,
int y1,
long Size)
Adds a tag of the form <string size="..." x="..." y="...">The String</string> to the Frame tag of this document. |
protected java.lang.String |
getColour(int iColour)
Transforms a Dasher colour identifier into an HTML-style #RRGGBB expression describing said colour. |
int |
GetHeight()
Gets the height, and hence maximum Y screen co-ordinate. |
int |
GetWidth()
Gets the width, and hence maximum X screen co-ordinate. |
void |
Polygon(CDasherView.Point[] Points,
int Number,
int Color)
See Polygon(CDasherView.Point[], int, int, int, boolean) |
void |
Polygon(CDasherView.Point[] Points,
int Number,
int Color,
int iWidth)
See Polygon(CDasherView.Point[], int, int, int, boolean) |
protected void |
Polygon(CDasherView.Point[] Points,
int Number,
int Color,
int iWidth,
boolean fill)
Adds a polygon to the XML document in the following format: |
void |
Polyline(CDasherView.Point[] Points,
int Number,
int iWidth)
See Polygon(CDasherView.Point[], int, int, int, boolean) |
void |
Polyline(CDasherView.Point[] Points,
int Number,
int iWidth,
int Colour)
See Polygon(CDasherView.Point[], int, int, int, boolean) |
void |
SendMarker(int iMarker)
Stub. |
void |
setAlphabets(java.util.ArrayList<java.lang.String> Alphs)
Sets the list of available alphabets to be recorded during the production of the <init> section produced for the first frame. |
void |
setColours(java.util.ArrayList<java.lang.String> Cols)
Sets the list of available colour schemes to be recorded during the production of the <init> section produced for the first frame. |
void |
SetColourScheme(CCustomColours ColourScheme)
Sets the colour scheme to use |
void |
setInitialAlph(java.lang.String alph)
Sets the default alphabet to be reported when this Screen draws its first frame. |
void |
setInitialCS(java.lang.String CS)
Sets the default colour scheme to be reported when this Screen draws its first frame. |
void |
setOutput(java.io.OutputStream out)
Sets the output stream to which XML should be serialized. |
CDasherView.Point |
TextSize(java.lang.String string,
int Size)
Determines / guesses the size of a given string as drawn on this screen. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean firstMessage
protected org.w3c.dom.Document drawInstructions
protected org.w3c.dom.Element root
protected org.w3c.dom.Element frame
protected CCustomColours m_ColourScheme
protected java.io.OutputStream m_Output
protected int sessID
protected java.util.Queue<CEditEvent> editEventQueue
protected java.util.ArrayList<java.lang.String> Alphabets
protected java.util.ArrayList<java.lang.String> Colours
protected java.lang.String initialCS
protected java.lang.String initialAlph
protected javax.xml.parsers.DocumentBuilder parser
protected javax.xml.transform.Transformer XMLSerializer
protected int m_Width
protected int m_Height
| Constructor Detail |
|---|
public NetScreen(int sessID,
int width,
int height)
Sets up a DocumentBuilder and Transformer for the production of XML and saves the height, width and session ID associated with this screen.
sessID - Session IDwidth - Screen width in pixelsheight - Screen height in pixels| Method Detail |
|---|
public void Blank()
In this specific case, a new Document is created and stored in drawInstructions, and required Elements message and frame are created and stored in root and frame respectively for use by other means.
Finally, if the firstMessage flag is true, the <init> section is created as described above.
Blank in interface CDasherScreenpublic void Display()
For the general contract of this method, see CDasherScreen.
Display in interface CDasherScreenpublic void setAlphabets(java.util.ArrayList<java.lang.String> Alphs)
Alphs - List of available alphabetspublic void setColours(java.util.ArrayList<java.lang.String> Cols)
Cols - List of available colour schemespublic void addEditEvent(CEditEvent event)
event - New EditEventprotected void addEditEvents()
public void DrawCircle(int iCX,
int iCY,
int iR,
int iColour,
boolean bFill)
The colour attributes are recorded in standard #RRGGBB format.
DrawCircle in interface CDasherScreeniCX - X co-ordinate of the centreiCY - Y co-ordinate of the centreiR - Radius in pixelsiColour - Colour numberbFill - Fill or outline?
public void DrawRectangle(int x1,
int y1,
int x2,
int y2,
int Color,
int iOutlineColour,
EColorSchemes ColorScheme,
boolean bDrawOutline,
boolean bFill,
int iThickness)
The colour attributes are recorded in standard #RRGGBB format.
DrawRectangle in interface CDasherScreenx1 - top left of rectangle (x coordinate)y1 - top left corner of rectangle (y coordinate)x2 - bottom right of rectangle (x coordinate)y2 - bottom right of rectangle (y coordinate)Color - the colour to be used (numeric)ColorScheme - Which colourscheme is to be usedbDrawOutline - Whether to draw an outline or notbFill - Whether to fill or notiThickness - Line thickness for outline
public void DrawString(java.lang.String string,
int x1,
int y1,
long Size)
The co-ordinates describe the top-left corner of a bounding rectangle.
DrawString in interface CDasherScreenstring - String to drawx1 - Top-left hand corner x co-ordinatey1 - Top-left hand corner y co-ordinateSize - Font size in pointspublic int GetHeight()
CDasherScreen
GetHeight in interface CDasherScreenpublic int GetWidth()
CDasherScreen
GetWidth in interface CDasherScreen
public void Polygon(CDasherView.Point[] Points,
int Number,
int Color,
int iWidth)
Polygon in interface CDasherScreenPoints - array of points defining the edge of the polygonNumber - number of points in the arrayColor - colour of the polygon (numeric)iWidth - Width of the polygon border to draw
protected void Polygon(CDasherView.Point[] Points,
int Number,
int Color,
int iWidth,
boolean fill)
<poly colour="..." fill="..." thickness="..."> <point x="..." y="..."/> <point x="..." y="..."/> ... </poly>
Points - Array of Points constituting the polygonNumber - Number of points in the polygonColor - Outline colouriWidth - Outline widthfill - Fill colour
public void Polygon(CDasherView.Point[] Points,
int Number,
int Color)
Polygon in interface CDasherScreenPoints - array of points defining the edge of the polygonNumber - number of points in the arrayColor - colour of the polygon (numeric)
public void Polyline(CDasherView.Point[] Points,
int Number,
int iWidth,
int Colour)
Polyline in interface CDasherScreenPoints - Array of Points describing the vertices of the line.Number - Number of pointsiWidth - Line widthColour - Colour number
public void Polyline(CDasherView.Point[] Points,
int Number,
int iWidth)
Polyline in interface CDasherScreenPoints - Array of Points describing the vertices of the line.Number - Number of pointsiWidth - Line widthpublic void SendMarker(int iMarker)
SendMarker in interface CDasherScreeniMarker - Marker numberpublic void SetColourScheme(CCustomColours ColourScheme)
CDasherScreen
SetColourScheme in interface CDasherScreenColourScheme - New colour scheme
public CDasherView.Point TextSize(java.lang.String string,
int Size)
CDasherScreenThis is used in determining how much to displace other drawn strings in order to prevent them from overlapping.
This must be carried out by the screen because only the actual drawing surface can know how fonts appear when rendered.
TextSize in interface CDasherScreenstring - String whose size we wish to determineSize - Font size in points
protected java.lang.String getColour(int iColour)
iColour - Colour index
public void setOutput(java.io.OutputStream out)
Typically this will be set prior to calling NewFrame, but it will take effect if set at any time before Display() is called.
out - OutputStream to which the next frame's XML should be writtenpublic void setInitialAlph(java.lang.String alph)
alph - Default alphabetpublic void setInitialCS(java.lang.String CS)
CS - Default colour scheme
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||