/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
@SuppressWarnings("serial")
boolean isStopped = false;
boolean fullUpdate = true;
int rows;
int columns;
public synchronized void init() {
title = "Spreadsheet";
}
rows = 9;
} else {
}
columns = 5;
} else {
}
char l[] = new char[1];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
cellWidth - 2,
cellHeight - 2);
l[0] = (char) ((int) 'a' + j);
}
}
}
addMouseListener(this);
addKeyListener(this);
}
return;
}
repaint();
}
public void stop() {
isStopped = true;
}
public void start() {
isStopped = false;
}
public void destroy() {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
}
}
}
}
return;
}
repaint();
}
if (!fullUpdate) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
if (cells[i][j].needRedisplay) {
}
}
}
} else {
paint(g);
fullUpdate = false;
}
}
public void recalculate() {
int i, j;
//System.out.println("SpreadSheet.recalculate");
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
cells[i][j].needRedisplay = true;
}
}
}
repaint();
}
float val = 0.0f;
//System.out.println("evaluateFormula:");
//n.print(3);
if (n == null) {
//System.out.println("Null node");
return val;
}
switch (n.type) {
switch (n.op) {
case '+':
break;
case '*':
break;
case '-':
break;
case '/':
break;
}
break;
//System.out.println("=>" + n.value);
return n.value;
//System.out.println("NULL at 193");
} else {
//System.out.println("=>" + cells[n.row][n.column].value);
}
}
//System.out.println("=>" + val);
return val;
}
int i, j;
char l[] = new char[1];
g.setColor(inputColor);
g.setColor(getBackground());
if (i < rows) {
}
}
for (i = 0; i < columns; i++) {
g.setColor(getBackground());
if (i < columns) {
l[0] = (char) ((int) 'A' + i);
g.drawString(new String(l),
cy);
}
}
for (i = 0; i < rows; i++) {
for (j = 0; j < columns; j++) {
}
}
}
g.setColor(getBackground());
d.width,
d.height - titleHeight,
false);
}
//1.1 event handling
}
int x = e.getX();
int y = e.getY();
if (y < (titleHeight + cellHeight)) {
selectedRow = -1;
}
e.consume();
}
if (x < rowLabelWidth) {
selectedRow = -1;
}
e.consume();
}
if (selectedRow > rows
|| selectedColumn >= columns) {
selectedRow = -1;
}
} else {
if (selectedRow >= rows) {
selectedRow = -1;
}
e.consume();
}
if (selectedRow != -1) {
}
requestFocus();
fullUpdate = true;
repaint();
}
e.consume();
}
}
}
}
}
}
fullUpdate = true;
inputArea.processKey(e);
e.consume();
}
}
return "Title: SpreadSheet \nAuthor: Sami Shaio \nA simple spread sheet.";
}
{ "title", "string",
"The title of the spread sheet. Default is 'Spreadsheet'" },
{ "rows", "int", "The number of rows. Default is 9." },
{ "columns", "int", "The number of columns. Default is 5." }
};
return info;
}
}
public volatile boolean run = true;
super("cell updater");
target = c;
}
public void run() {
try {
new InputStreamReader(dataStream)));
tokenStream.eolIsSignificant(false);
while (run) {
switch (tokenStream.nextToken()) {
case StreamTokenizer.TT_EOF:
dataStream.close();
return;
default:
break;
case StreamTokenizer.TT_NUMBER:
}
break;
}
try {
} catch (InterruptedException e) {
break;
}
}
} catch (IOException e) {
return;
}
}
}
class Cell {
boolean needRedisplay;
boolean selected = false;
boolean transientValue = false;
float value;
int width;
int height;
boolean paused = false;
int width,
int height) {
this.highlightColor = highlightColor;
needRedisplay = true;
}
public void setRawValue(float f) {
value = f;
}
public void setValue(float f) {
setRawValue(f);
paused = false;
app.recalculate();
needRedisplay = true;
}
public void setTransientValue(float f) {
transientValue = true;
value = f;
needRedisplay = true;
app.recalculate();
}
switch (s.charAt(0)) {
case 'v':
break;
case 'f':
break;
case 'l':
break;
case 'u':
break;
}
}
/**
* Parse a spreadsheet formula. The syntax is defined as:
*
* formula -> value
* formula -> value op value
* value -> '(' formula ')'
* value -> cell
* value -> <number>
* op -> '+' | '*' | '/' | '-'
* cell -> <letter><number>
*/
char op;
return null;
}
//System.out.println("subformula = " + subformula);
//System.out.println("Parse succeeded");
return null;
}
//System.out.println("Parse failed");
return formula;
}
// parse an operator and then another value
case 0:
//System.out.println("Parse succeeded");
return null;
case ')':
//System.out.println("Returning subformula=" + subformula);
return subformula;
case '+':
case '*':
case '-':
case '/':
//System.out.println("subformula(2) = " + subformula);
equals(restFormula)) {
//System.out.println("Parse succeeded");
//node.print(3);
return subformula;
} else {
//System.out.println("Parse failed");
return formula;
}
default:
//System.out.println("Parse failed (bad operator): " + subformula);
return formula;
}
}
float _value;
int row;
int column;
//System.out.println("parseValue: " + formula);
if (c == '(') {
//System.out.println("parseValue(" + formula + ")");
//System.out.println("rest=(" + subformula + ")");
if (subformula == null
//System.out.println("Failed");
return formula;
//System.out.println("Failed (missing parentheses)");
return formula;
}
} else if (c >= '0' && c <= '9') {
int i;
//System.out.println("formula=" + formula);
if ((c < '0' || c > '9') && c != '.') {
break;
}
}
try {
} catch (NumberFormatException e) {
//System.out.println("Failed (number format error)");
return formula;
}
//node.print(3);
//System.out.println("value= " + value + " i=" + i +
// " rest = " + restFormula);
return restFormula;
} else if (c >= 'A' && c <= 'Z') {
int i;
column = c - 'A';
c = restFormula.charAt(i);
if (c < '0' || c > '9') {
break;
}
}
//System.out.println("row = " + row + " column = " + column);
//node.print(3);
if (i == restFormula.length()) {
restFormula = null;
} else {
return null;
}
}
}
return restFormula;
}
paused = false;
updaterThread.run = false;
}
valueString = s;
needRedisplay = true;
switch (type) {
break;
break;
updaterThread = new CellUpdater(this);
break;
break;
}
app.recalculate();
}
return valueString;
}
return printString;
}
public void select() {
selected = true;
paused = true;
}
public void deselect() {
selected = false;
paused = false;
needRedisplay = true;
}
if (selected) {
} else {
}
if (valueString != null) {
switch (type) {
break;
break;
break;
}
if (transientValue) {
} else {
} else {
}
}
}
needRedisplay = false;
}
}
class Node {
int type;
int row;
int column;
float value;
char op;
public Node() {
value = 0;
row = -1;
column = -1;
op = 0;
}
}
for (int i = 0; i < ind; i++) {
}
}
char l[] = new char[1];
switch (type) {
break;
break;
break;
}
}
}
class InputField {
char buffer[];
int nChars;
int width;
int height;
nChars = 0;
}
}
int i;
for (i = 0; i < maxchars; i++) {
buffer[i] = 0;
}
sval = "";
} else {
}
}
return sval;
}
}
}
char ch = e.getKeyChar();
switch (ch) {
case '\b': // delete
if (nChars > 0) {
nChars--;
}
break;
case '\n': // return
selected();
break;
default:
}
}
}
}
public void selected() {
}
}
class SpreadSheetInput
extends InputField {
int width,
int height,
}
public void selected() {
float f;
case 'v':
try {
int i;
for (i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c < '0' || c > '9') {
break;
}
}
s = s.substring(0, i);
} catch (NumberFormatException e) {
}
break;
case 'l':
break;
case 'u':
break;
case 'f':
break;
}
}
}