Methods
bracketClosure()
returns index of bracket closure from a string
s = given string
b = bracket style (start bracket)
t = index (number or indexOf(string))
- Source:
changeAttributesToJSX(a) → {Object}
Changes some attributes from original Java Sketchpad code into form that JSXGraph can understand
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | object a is created from original code and has the values that will be changed |
- Source:
Returns:
a - return object a with changed values
- Type
- Object
changeOptionsToJSX(a) → {Object}
Changes some values in original Java Sketchpad code into form that JSXGraph can understand.
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | object a is created from original code and has the values that will be changed |
- Source:
Returns:
a - return object a with changed values
- Type
- Object
changePosInfoToJSX(a, applets, coordd, scx, scy, hasoriginunit) → {Object}
Changes property Pos of an element given as object created in sketchpadrowToJsxgElement(string)
Outcome depends of type of the element as follows:
- Point will change Pos to array with point coordinates [x,y],
- Unit coord will change Pos to array with reference to object and a coordinate [ref to obj, y],
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | - |
applets |
Array | - |
coordd |
Int | coord divider, this is read from the original code in the main function JSPtoSJX |
scx |
Double | scale x factor, this is read in the main function |
scy |
Double | scale y factor, this is read in the main function |
hasoriginunit |
Int | origin&unit info read in the main function from the original code |
- Source:
Returns:
a - return the object with changed values
...
- Type
- Object
changeToCoord(x, y, appletsize, coord_div, scalex, scaley, hasorigin) → {Array}
Function to change coordinates so that the (0,0) is the origo.
Parameters:
Name | Type | Description |
---|---|---|
x |
Int | x coordinate in Java Sketchpad form |
y |
Int | y coordinate in Java Sketchpad form |
appletsize |
Array.<Int> | appletsize |
coord_div |
Int | coordinates dividor if coordinates has been set in Java Sketchpad code using Origin&Unit and Unitpoint commands |
scalex |
Double | factor that is used in scaling the image horizontally |
scaley |
Double | factor that is used in scaling the image vertically (this is not actually used, since the scalex and scaley are defines as the same value in main function) |
hasorigin |
String | coordinates of origin if it has been changes in original Java Sketchapd code |
- Source:
Returns:
- created coordinates (Array)
- Type
- Array
changeTypeToJSX(a) → {Object}
Changes property JsxType of an element given as object created in sketchpadrowToJsxgElement(string)
[mostly just changes property to lowercase letters]
Also change the CType (constructor type), possible types are:
points, straightlines, circles, measurements, transformations, images, buttons, coordinatesystem, locus
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | - |
- Source:
Returns:
a - return the object
- Type
- Object
checkJSPitem(p) → {boolen}
Check if param p is valid JSP constructor or not. Return true in case p is JSP constructor, else false
Parameters:
Name | Type | Description |
---|---|---|
p |
String | string value JSP constructor |
- Source:
Returns:
true if p is JSP type constructor, else false
- Type
- boolen
checkJSPStyle(c) → {Boolean}
Check if input (string) is jspcode with $variables
Parameters:
Name | Type | Description |
---|---|---|
c |
String | JSP code |
- Source:
Returns:
- Type
- Boolean
cleanString(s) → {String}
Simple string cleaning function (trim and replace all ' with "), return changed s (String).
Parameters:
Name | Type | Description |
---|---|---|
s |
String | string |
- Source:
Returns:
s - "cleaned" string
- Type
- String
codeDummyTest(code) → {Boolean}
To check code for simple errors which are length, brackets etc.
Parameters:
Name | Type | Description |
---|---|---|
code |
String | - |
- Source:
Returns:
valid - true if code passes dummy-test, else false
- Type
- Boolean
createJspCodeObject(a) → {Object}
Divides one big string file (original Java Sketchpad code) into array of separate rows and returns rows info as an Object.
Parameters:
Name | Type | Description |
---|---|---|
a |
String | Java Sketchpad code -string |
- Source:
Returns:
jspObj - separated rows from Java Sketchpad code as an object
- Type
- Object
createLabelAlign(l, a) → {String}
This function creates label offset for the elements in jsxgboard
Parameters:
Name | Type | Description |
---|---|---|
l |
String | value given in UI, direction for moving label |
a |
String | value is how much to move the label |
- Source:
Returns:
- attribute to change label position in JSXGraph image
- Type
- String
getCircleAnimationPath(object, type, direction) → {String}
Calculates and returns path for the animation
Parameters:
Name | Type | Description |
---|---|---|
object |
Strign | object in convertor |
type |
String | type of an object |
direction |
Int | direction of the animation, possible values are 0 or 1, if not given direction will be 1 |
- Source:
Returns:
path - retuns path as a string that has the array in it
- Type
- String
getNumberOfCharForClaculation(a) → {Int}
Simple function to get number of char for the Calculate operation (get order of variable)
Parameters:
Name | Type | Description |
---|---|---|
a |
String | alphabet from A to F |
- Source:
Returns:
integer from 0 to 5
- Type
- Int
getOrigin(a) → {String}
Checks if there is Origin&Unit constructor in code, and return originelements rownr (String).
Parameters:
Name | Type | Description |
---|---|---|
a |
String | original Java Sketchpad code |
- Source:
Returns:
org - information that is in the Origin&Unit line between the brackets '(' and ')'
- Type
- String
getWidthHeight(codetxt) → {Object}
Get width and height values from code (string)
Parameters:
Name | Type | Description |
---|---|---|
codetxt |
String | code |
- Source:
Returns:
[array] - array that has dimension values: [width, height]
- Type
- Object
gliderPoint(a, b, c) → {Array}
Function that creates and returns (Array) position of the glider point.
Param variables are string and number(a,b).
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | JSXGraph Object |
b |
Double | this is to set the glider point |
c |
Object | Object circle |
- Source:
Returns:
- coordinates for moving glider to right position
- Type
- Array
inputCodeAndValues(codetxt) → {Boolea}
This function checks some things from string (the JSP code), inputs code into codearea and runs function jspToJsx
Parameters:
Name | Type | Description |
---|---|---|
codetxt |
String | code as string |
- Source:
Returns:
- false if codetxt not found, else true;
- Type
- Boolea
jspToJsx(code_input, size_input, elementname_input, isFullPageConvert) → {String}
JAVASKETCHPAD TO JSXGRAPH CONVERTER : MAIN FUNCTION
This is the main function, that creates converted JSXGraph code from code-input and other input elements.
This function connects all the parts that are needed when constructing JSXG element from JSP element.
Input variables are:
code_input that is jsp code we want to convert (String)
size_input (optional) has table size information as width and height for example [400,400] (Array)
elementname_input (optional) has the element name information (String)
isFullPageConvert (optional) has the info if we are using fullpage convertor (boolean)
Parameters:
Name | Type | Description |
---|---|---|
code_input |
String | original Java Sketchpad code |
size_input |
Array.<Int> | tablesize |
elementname_input |
String | element name |
isFullPageConvert |
Boolean | if is full page conver |
- Source:
Returns:
codestring - fully converted code to JSXGraph
- Type
- String
mathCalc(f, a, b) → {String}
Creates one calculation with given operator and inputs. Second input is optional.
E.g. mathCalc("+", "1", "5") returns string "(1+5)" and
mathCalc("@sin_", "3.14") returns string "Math.sin(3.14)".
Parameters:
Name | Type | Description |
---|---|---|
f |
String | mathematical operation |
a |
String | mathematical value or expression |
b |
String | mathematical value or expression |
- Source:
Returns:
mathematical expression as a JavaScript string
- Type
- String
openSelectionFile(folder, file)
Open file fron path and convert it
Parameters:
Name | Type | Description |
---|---|---|
folder |
String | folder name |
file |
String | file name with extension |
- Source:
rgbToHex(R, G, B) → {String}
Help function to change colour from RBG to Hex
source: http://www.javascripter.net/faq/rgbtohex.htm
Parameters:
Name | Type | Description |
---|---|---|
R |
String | - |
G |
String | - |
B |
String | - |
- Source:
Returns:
toHex(R)+toHex(G)+toHex(B) - calculated Hex-colour
- Type
- String
separateCommands(a) → {Array.<String>}
Divides one string file (original Java Sketchpad code) into array of separate rows and returns rows (Array).
Parameters:
Name | Type | Description |
---|---|---|
a |
String | Java Sketchpad code -string |
- Source:
Returns:
rows - separated rows from Java Sketchpad code as an array
- Type
- Array.<String>
setAttributes(e, s) → {String}
Get options as a full string {options}, that has all the options that are needed in construction of this object.
The purpose of this function is to shorten the converted code.
This is also to make changing of defaul options easier (for example point color).
Parameters:
Name | Type | Description |
---|---|---|
e |
Object | Object that has option values |
s |
String | optional, extra option to add options string. This is for some special attributes. Function just adds s in the return string. |
- Source:
Returns:
options - String that has only the options needed, for example {name:'A', color:'red'}. There will be no options that values are default in JSXgraph syntax
- Type
- String
sketchpadrowToJsxgElement(a) → {Object}
Slices one row of JavaSketchpad code to javascript object that has following informtion:
- Row (row number in sketchpad code),
- Type (Type of sketchpad element as sketchpad constructor),
- JsxType (type as javascript understands element [in this algorithm]),
- Pos (includes info about position [x- and y-coordinates], possible name [buttons, texts, measurements] or/and objects [rows] that are referred to),
- Opts (sliced string from '[' to ']' in sketchpad code),
- Att (specific info included in Opts [sketchpad code sliced from '[' to ']'] as a jsxgraph attributes. This info includes following attributes:
Name, Color, Fixed, Visible, WithLabel, StrokeWidth, Straightlast, Straightfirst, AnchorX, Trace, Size, Infobox, LabelAlign
- Anim (has the info needed to create buttons [list of the objects (rows) referred to when creating a button],
Parameters:
Name | Type | Description |
---|---|---|
a |
String | One row of Java Sketchpad code |
- Source:
Returns:
el - Object that has information separated from original Java Sketchpad element
- Type
- Object
toHex(n) → {String}
Help function to change colour from RBG to Hex
source: http://www.javascripter.net/faq/rgbtohex.htm
Parameters:
Name | Type | Description |
---|---|---|
n |
String | value to be changed |
- Source:
Returns:
changed Hex-value
- Type
- String
varJSPtoNumJSP(c) → {String}
Changes all input code $name variablenames to {rownumber} representation and returns changed code (string)
Parameters:
Name | Type | Description |
---|---|---|
c |
String | JSP code in $-form |
- Source:
Returns:
c - JAva Sketchpad code in {row no}-form
- Type
- String