Name |
Type |
Description |
Data1 |
stringconstant |
Valuehttp://robjhyndman.com/tsdldata/data/andrews2.dat |
getData2Page |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
}
else {
inputURL = new URL(url);
}
URLConnection con = inputURL.openConnection();
InputStream in = con.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
Reader inReader = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
int ch;
while ((ch = inReader.read()) > -1) {
buf.append((char)ch);
}
inReader.close();
contents = buf.toString();
//String NEWLINE = System.getProperty("line.separator");
//
//URL inputURL = null;
//if (base != void) {
// inputURL = new URL(new URL(base), url);
//} else {
// inputURL = new URL(url);
//}
//StringBuffer result = new StringBuffer();
//BufferedReader reader = new BufferedReader(new InputStreamReader(inputURL.openStream()));
//String line = null;
//while ((line = reader.readLine()) != null) {
// result.append(line);
// result.append(NEWLINE);
//}
//
//contents = result.toString();
|
Data2 |
stringconstant |
Valuehttp://robjhyndman.com/tsdldata/data/andrews3.dat |
Split_string_into_string_list_by_regular_expression |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.trim().split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
//Modified local worker by Trisha Adamus |
Separator1 |
stringconstant |
Value {1,2} |
GenerateGraphURL |
beanshell |
Scriptimport java.text.*;
import java.net.URLEncoder;
StringBuilder sb = new StringBuilder();
sb.append("http://chart.apis.google.com/chart?");
//Chart type lc for line chart
sb.append("cht=lc");
// Chart Size
sb.append("&chs=1000x300");
//Which axis should show
// add r for right side numbers
// add additional xyr for labels
sb.append("&chxt=x,y,r,x,y,r");
//Edit labels when using new data
//Chart labels , Add labels as 2nd set of axis
sb.append("&chxl=3:|Year|4:|Number|5:|Price|");
// Position the labels for axis 3,4,5 at 50 ( the center )
sb.append("&chxp=3,50|4,50|5,50");
// Chart Colors
sb.append("&chco=FF0000,00FF00,0000FF,999900");
//Edit title when using new data
//Add label to the series of data
// %20 is for space
sb.append("&chdl=Number%20of%20Pelts|Price%20per%20Pelt");
//Chart title provided by input
if (title != void) {
sb.append("&chtt=");
// urlencode to fix for spaces
sb.append(URLEncoder.encode(title));
}
//Collect a list of max values for specifying data ranges
ArrayList maxes = new ArrayList();
//Use a formater to get nice looking numbers for google
DecimalFormat df = new DecimalFormat("###.##");
//Output the data
if (data != void) {
sb.append("&chd=t:");
for (int i = 0; i < data.size(); i++) {
List data1 = (List) data.get(i);
//Google only likes numbers between 0 and 100
//find max to use to convert numbers into percentage of max
Float max = 0.0;
for (int j = 0; j < data1.size(); j++) {
Float value = Float.parseFloat(data1.get(j));
if ( max < value )
max = value;
}
maxes.add( max ); //add max to collection for use during range calc
for (int j = 0; j < data1.size(); j++) {
Float value = Float.parseFloat(data1.get(j));
value = value/max *100; // convert value to percent of max
sb.append( df.format(value) ); //Format the float for google
if (j+1 < data1.size()) {
sb.append(",");
}
}
if (i+1 < data.size()) {
sb.append("|");
}
}
}
//Edit range when using new data with different year ranges
//Axis Range ,,,|
sb.append("&chxr=0,1857,1911,2");
for ( int i = 0; i < maxes.size(); i++){
sb.append("|"+ (i+1) +",0," ); //specify axis and start ( at zero)
sb.append( maxes.get(i).intValue() + "," ); // specify max
sb.append( (maxes.get(i).intValue()/10 )); // specify count by
// to make things simple this will show 10 even
// spaced ticks on each side of the graph
}
//Write the URL to the output
graphURL = sb.toString();
//Modified by Trisha Adamus and Jeffery Adamus
//from Spreadsheet Data Import Example by Alan Williams |
Get_Image_From_URL |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
} else {
inputURL = new URL(url);
}
byte[] contents;
if (inputURL.openConnection().getContentLength() == -1) {
// Content size unknown, must read first...
byte[] buffer = new byte[1024];
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
totalBytesRead += bytesRead;
bytesRead = is.read(buffer, 0, 1024);
}
contents = new byte[totalBytesRead];
} else {
contents = new byte[inputURL.openConnection().getContentLength()];
}
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
bytesRead = is.read(contents, totalBytesRead, contents.length - totalBytesRead);
totalBytesRead += bytesRead;
if (contents.length==totalBytesRead) break;
}
image = contents;
|
getCitationPage |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
}
else {
inputURL = new URL(url);
}
URLConnection con = inputURL.openConnection();
InputStream in = con.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
Reader inReader = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
int ch;
while ((ch = inReader.read()) > -1) {
buf.append((char)ch);
}
inReader.close();
contents = buf.toString();
//String NEWLINE = System.getProperty("line.separator");
//
//URL inputURL = null;
//if (base != void) {
// inputURL = new URL(new URL(base), url);
//} else {
// inputURL = new URL(url);
//}
//StringBuffer result = new StringBuffer();
//BufferedReader reader = new BufferedReader(new InputStreamReader(inputURL.openStream()));
//String line = null;
//while ((line = reader.readLine()) != null) {
// result.append(line);
// result.append(NEWLINE);
//}
//
//contents = result.toString();
|
URLForCitation |
stringconstant |
Valuehttp://robjhyndman.com/TSDL/ |
getCurrentDateString |
beanshell |
Scriptimport java.text.*;
Date currentDate = new Date();
SimpleDateFormat df = DateFormat.getDateInstance();
String format = "MM/dd/yyyy";
if ( dateFormat != void ){
format = dateFormat;
}
df.applyPattern( format );
String stringDate = df.format( currentDate );
//Beanshell to acquire current date
//Written by Jeffery Adamus |
extractULElementForCitationFromTSDL |
localworker |
Script
// Copied and Hacked by Jeffery Adamus
// based on getImageLinks by Alan Williams
String lowerCaseContent = document.toLowerCase();
int index = 0;
int endUL = 0;
List ulElements = new ArrayList();
while ((index = lowerCaseContent.indexOf(" ", index)) != -1) {
index+= 4;
if (( endUL = lowerCaseContent.indexOf(" ", index)) == -1){
debugLog += " break" + endUL;
break;
}
String strLink = document.substring(index, endUL);
index = endUL;
if ( strLink.indexOf( " |
citationLinePlusDate |
beanshell |
Scriptint i = 0;
i = citationLine.indexOf("<");
citationLine = citationLine.substring(0,i);
citationLine = citationLine + date + ".";
|
Split_string_into_string_list_by_regular_expression_2 |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.trim().split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
//Modified local worker by Trisha Adamus |
Separator2 |
stringconstant |
Value {1,3} |
CombineData |
beanshell |
Scriptdataout = new ArrayList();
//Add the input data series to a depth of 2 data series
dataout.add( data1 );
dataout.add( data2 );
//Beanshell written by Trisha Adamus |
String_constant |
stringconstant |
ValuePelt Volume and Price per Year |
getData1Page |
localworker |
ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
}
else {
inputURL = new URL(url);
}
URLConnection con = inputURL.openConnection();
InputStream in = con.getInputStream();
InputStreamReader isr = new InputStreamReader(in);
Reader inReader = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
int ch;
while ((ch = inReader.read()) > -1) {
buf.append((char)ch);
}
inReader.close();
contents = buf.toString();
//String NEWLINE = System.getProperty("line.separator");
//
//URL inputURL = null;
//if (base != void) {
// inputURL = new URL(new URL(base), url);
//} else {
// inputURL = new URL(url);
//}
//StringBuffer result = new StringBuffer();
//BufferedReader reader = new BufferedReader(new InputStreamReader(inputURL.openStream()));
//String line = null;
//while ((line = reader.readLine()) != null) {
// result.append(line);
// result.append(NEWLINE);
//}
//
//contents = result.toString();
|
Comments (0)
No comments yet
Log in to make a comment