294 lines
8.3 KiB
Plaintext
294 lines
8.3 KiB
Plaintext
// cell = mCells[mSelectedRow][mSelectedColumn];
|
|
// if(null!=cell.getPrintString())mInputArea.setText(new String(cell.getPrintString()));
|
|
// else mInputArea.setText(new String(""));
|
|
// if(mCurrent!=null)mCurrent.deselect();
|
|
// mCurrent=cell;
|
|
// mCurrent.select();
|
|
// requestFocus();
|
|
// mFullUpdate = true;
|
|
// repaint();
|
|
|
|
|
|
// graphics.fillRect(x,y,mWidth-1,mHeight);
|
|
|
|
|
|
if(mTransientValue)graphics.drawString("" + mValue,x,y+(mHeight/2)+5);
|
|
else
|
|
{
|
|
if(mValueString.length() > 14)graphics.drawString(mValueString.substring(0,14),x,y+(mHeight/2)+5);
|
|
else graphics.drawString(mValueString,x,y+(mHeight/2)+5);
|
|
}
|
|
|
|
|
|
|
|
public synchronized void paint(Graphics graphics)
|
|
{
|
|
int i;
|
|
int j;
|
|
int cx;
|
|
int cy;
|
|
char strLabel[]=new char[1];
|
|
|
|
Dimension clientRect=size();
|
|
graphics.setFont(mTitleFont);
|
|
graphics.drawString(mStrTitle,(clientRect.width-graphics.getFontMetrics().stringWidth(mStrTitle))/2,12);
|
|
graphics.setColor(mInputColor);
|
|
graphics.fillRect(0,mCellDimension.height,clientRect.width,mCellDimension.height);
|
|
graphics.setFont(mTitleFont);
|
|
for(i=0;i<mRows+1;i++)
|
|
// for(i=mStartDisplayRow;i<mRows;i++)
|
|
{
|
|
cy=(i+2)*mCellDimension.height;
|
|
graphics.setColor(getBackground());
|
|
graphics.draw3DRect(0,cy,clientRect.width,2,true);
|
|
if(i<mRows)
|
|
{
|
|
// graphics.setColor(Color.red);
|
|
// graphics.drawString(""+(i+1),2,cy+12);
|
|
|
|
|
|
graphics.setColor(getBackground());
|
|
graphics.fillRect(1,cy+1,mRowLabelWidth-1,(2*mCellDimension.height)-2);
|
|
graphics.setColor(Color.red);
|
|
graphics.drawString(""+(i+1+mStartDisplayRow),2,cy+12);
|
|
|
|
}
|
|
}
|
|
graphics.setColor(Color.red);
|
|
for(i=0;i<mColumns;i++)
|
|
{
|
|
cx=i*mCellDimension.width;
|
|
graphics.setColor(getBackground());
|
|
graphics.draw3DRect(cx+mRowLabelWidth,2*mCellDimension.height,1,clientRect.height,true);
|
|
|
|
// if(i<mColumns)
|
|
// {
|
|
// graphics.setColor(Color.red);
|
|
// strLabel[0]=(char)((int)'A'+i);
|
|
// l[0]=(char)((int)'A'+i);
|
|
// graphics.drawString(new String(strLabel),cx+mRowLabelWidth+(mCellDimension.width/2),clientRect.height-3);
|
|
// }
|
|
}
|
|
|
|
for(i=0;i<mRows;i++) // for(i=mStartDisplayRow;i<mRows;i++)
|
|
{
|
|
for(j=0;j<mColumns;j++)
|
|
{
|
|
cx=(j*mCellDimension.width)+2+mRowLabelWidth;
|
|
cy=((i+1)*mCellDimension.height)+2+mTitleHeight;
|
|
if(mCells[i+mStartDisplayRow][j]!=null)mCells[i+mStartDisplayRow][j].paint(graphics,cx,cy);
|
|
}
|
|
}
|
|
|
|
graphics.setColor(getBackground());
|
|
graphics.draw3DRect(0,mTitleHeight,clientRect.width,clientRect.height-mTitleHeight,false);
|
|
mInputArea.paint(graphics,1,mTitleHeight+1);
|
|
|
|
}
|
|
-c
|
|
|
|
|
|
graphics.setColor(Color.red);
|
|
for(i=0;i<mColumns;i++)
|
|
{
|
|
cx=i*mCellDimension.width;
|
|
graphics.setColor(getBackground());
|
|
graphics.draw3DRect(cx+mRowLabelWidth,2*mCellDimension.height,1,clientRect.height,true);
|
|
|
|
// if(i<mColumns)
|
|
// {
|
|
// graphics.setColor(Color.red);
|
|
// strLabel[0]=(char)((int)'A'+i);
|
|
// l[0]=(char)((int)'A'+i);
|
|
// graphics.drawString(new String(strLabel),cx+mRowLabelWidth+(mCellDimension.width/2),clientRect.height-3);
|
|
// }
|
|
}
|
|
|
|
|
|
// for(i=0;i<mRows;i++) // for(i=mStartDisplayRow;i<mRows;i++)
|
|
// {
|
|
// for(j=0;j<mColumns;j++)
|
|
// {
|
|
// cx=(j*mCellDimension.width)+2+mRowLabelWidth;
|
|
// cy=((i+1)*mCellDimension.height)+2+mTitleHeight;
|
|
// if(mCells[i+mStartDisplayRow][j]!=null)mCells[i+mStartDisplayRow][j].paint(graphics,cx,cy);
|
|
// }
|
|
// }
|
|
|
|
|
|
public void paint(Graphics graphics,int x,int y)
|
|
{
|
|
if(mSelected)graphics.setColor(mHighlightColor);
|
|
else graphics.setColor(mBgColor);
|
|
// graphics.fillRect(x+1,y+1,mWidth-2,mHeight-2);
|
|
graphics.fillRect(x+1,y+1,mWidth-1,mHeight-1);
|
|
if(null!=mValueString)
|
|
{
|
|
switch(mType)
|
|
{
|
|
case Cell.VALUE:
|
|
case Cell.LABEL:
|
|
graphics.setColor(mFgColor);
|
|
break;
|
|
case Cell.FORMULA:
|
|
graphics.setColor(Color.red);
|
|
break;
|
|
case Cell.URL:
|
|
graphics.setColor(Color.blue);
|
|
break;
|
|
}
|
|
if(!mTransientValue)
|
|
{
|
|
if(mValueString.length()>14)graphics.drawString(mValueString.substring(0,14),x,y+(mHeight/2)+5);
|
|
else graphics.drawString(mValueString,x,y+(mHeight/2)+5);
|
|
}
|
|
else graphics.drawString(""+mValue,x,y+(mHeight/2)+5);
|
|
mNeedRedisplay=false;
|
|
}
|
|
}
|
|
|
|
|
|
//******************************************************************************************************
|
|
// ***************************************** CELLTHREAD ***********************************************
|
|
//******************************************************************************************************
|
|
class CellThread extends Thread
|
|
{
|
|
private Cell mTarget;
|
|
private InputStream mDataStream=null;
|
|
private StreamTokenizer mTokenStream;
|
|
|
|
public CellThread(Cell cell)
|
|
{
|
|
super("CellThread");
|
|
mTarget=cell;
|
|
}
|
|
public void run()
|
|
{
|
|
try
|
|
{
|
|
mDataStream = new URL(mTarget.spreadSheet().applet().getDocumentBase(),mTarget.getValueString()).openStream();
|
|
mTokenStream = new StreamTokenizer(mDataStream);
|
|
mTokenStream.eolIsSignificant(false);
|
|
while(true)
|
|
{
|
|
switch(mTokenStream.nextToken())
|
|
{
|
|
case mTokenStream.TT_EOF:
|
|
mDataStream.close();
|
|
return;
|
|
default:
|
|
break;
|
|
case mTokenStream.TT_NUMBER:
|
|
mTarget.setTransientValue((float)mTokenStream.nval);
|
|
if(!mTarget.spreadSheet().stopped()&&!mTarget.paused())mTarget.spreadSheet().applet().repaint();
|
|
break;
|
|
}
|
|
try {Thread.sleep(2000);}
|
|
catch(InterruptedException exception){break;}
|
|
}
|
|
}
|
|
catch (IOException exception){return;}
|
|
}
|
|
}
|
|
|
|
|
|
// if(mType == Cell.URL)
|
|
// {
|
|
// mCellThread.stop();
|
|
// mCellThread=null;
|
|
// }
|
|
|
|
|
|
// mCellThread = new CellThread(this);
|
|
// mCellThread.start();
|
|
|
|
|
|
// public CellThread cellThread()
|
|
// {
|
|
// return mCellThread;
|
|
// }
|
|
|
|
|
|
//import java.awt.Font;
|
|
//import java.awt.Graphics;
|
|
//import java.awt.Color;
|
|
//import java.util.Date;
|
|
//import java.awt.Frame;
|
|
//import java.awt.image.*;
|
|
|
|
//import java.applet.*;
|
|
//import java.util.*;
|
|
//import java.net.*;
|
|
|
|
|
|
|
|
|
|
public synchronized void paint(Graphics graphics)
|
|
{
|
|
char strLabel[]=new char[1];
|
|
int i;
|
|
int j;
|
|
int cx;
|
|
int cy;
|
|
|
|
graphics.setFont(mTitleFont);
|
|
graphics.drawString(mStrTitle,(mControlDimension.width-graphics.getFontMetrics().stringWidth(mStrTitle))/2,12);
|
|
graphics.setColor(mInputColor);
|
|
// graphics.fillRect(0,mCellDimension.height,mControlDimension.width,mCellDimension.height);
|
|
// graphics.setFont(mTitleFont);
|
|
// drawGrid(graphics);
|
|
for(i=mStartDisplayRow;i<mRows;i++)
|
|
{
|
|
for(j=mStartDisplayColumn;j<mColumns;j++)
|
|
{
|
|
cx=((j-mStartDisplayColumn)*mCellDimension.width)+2+mRowLabelWidth;
|
|
cy=((i+1-mStartDisplayRow)*mCellDimension.height)+2+mTitleHeight;
|
|
if(mCells[i][j]!=null)mCells[i][j].paint(graphics,cx,cy);
|
|
}
|
|
}
|
|
graphics.setColor(mApplet.getBackground());
|
|
graphics.draw3DRect(0,mTitleHeight,mControlDimension.width,mControlDimension.height-mTitleHeight,false);
|
|
mInputArea.paint(graphics,1,mTitleHeight+1);
|
|
}
|
|
|
|
|
|
|
|
// if(!mTransientValue)
|
|
// {
|
|
//
|
|
// if(mValueString.length()>14)graphics.drawString(mValueString.substring(0,14),x,y+(mHeight/2)+5);
|
|
// else graphics.drawString(mValueString,x,y+(mHeight/2)+5);
|
|
//
|
|
// String printString;
|
|
// if(mValueString.length()>14)printString=new String(mValueString.substring(0,14));
|
|
// else printString=mValueString;
|
|
// FontMetrics metrics=graphics.getFontMetrics();
|
|
// int stringWidth=metrics.stringWidth(printString);
|
|
// if(x+stringWidth<mSpreadSheet.controlDimension().width)graphics.drawString(printString,x,y+(mHeight/2)+5);
|
|
//
|
|
// }
|
|
// else graphics.drawString(""+mValue,x,y+(mHeight/2)+5);
|
|
|
|
public void setText(String val)
|
|
{
|
|
int i;
|
|
|
|
if(val==null)
|
|
{
|
|
mStringValue=new String("");
|
|
mChars=0;
|
|
mBuffer[0]=0;
|
|
}
|
|
else
|
|
{
|
|
for(i=0;i<mMaxChars;i++)mBuffer[i]=0;
|
|
mStringValue=new String(val);
|
|
mStringValue.getChars(0,mStringValue.length(),mBuffer,0);
|
|
// mChars=val.length();
|
|
// mStringValue=new String(mBuffer);
|
|
for(i=0;mBuffer[i]!=0&&i<mMaxChars;i++);
|
|
mChars=i;
|
|
mStringValue=new String(mBuffer).substring(0,i);
|
|
}
|
|
}
|