AMADEUS html plain
This sketchy text is generated by AMADEUS
import java.io.*;
import java.awt.*;
import java.util.*;
class Row extends Rectangle
Vector elements;
transient int maxDescent;
transient Symbol sy;
transient AmImage im;
transient HyperElement hy;
transient int prevX;
transient int prevY;
transient int prevW;
transient int prevH;
Row(Font font, Color color)
elements = new Vector();
width = 0; height = 0;
insert(new Symbol(Default.leadingChar, font, color), 0);
x = -1;
y = -1;
width = -1;
height = -1;
planSize();
Row(Color color)
elements = new Vector();
width = 0; height = 0;
insert(new Symbol(Default.leadingChar, color), 0);
x = -1;
y = -1;
width = -1;
height = -1;
planSize();
Row(String s, Color color)
this(color);
Symbol symbol;
* int i = 0; i < s.length(); i++
symbol = new Symbol(s.charAt(i), Default.font, color);
insert(symbol, i+1);
x = -1;
y = -1;
width = -1;
height = -1;
planSize();
Object element(int i)
<======elements.elementAt(i)
void getElement(int i)
Object o = element(i);
? o instanceof Symbol
sy = (Symbol)o;
im = null;
hy = null;
<======
? o instanceof AmImage
sy = null;
im = (AmImage)o;
hy = null;
<======
sy = null;
im = null;
hy = (HyperElement)o;
int width(int i, int j)
int w = 0;
* int k = i; k <= j; k++
getElement(k);
? sy != null
w += sy.width();
<------
? im != null
w += im.width();
<------
<======w
public boolean isTrivial()
* int i = 1; i < elements.size(); i++
<==============false
? sy != null
? sy.c != ' '
<==========false
<======true
boolean isRichModel()
* int i = 0, n = elements.size(); i < n; i++
getElement(i);
? (im != null) || (hy != null)
<==========true
? (sy != null) && (((int)(sy.c)) > 255)
<==========true
<======false
void insert(Symbol s, int i)
elements.insertElementAt(s, i);
void append(Symbol s)
void insert(AmImage im, int i)
elements.insertElementAt(im,i);
void insert(HyperElement hy, int i)
elements.insertElementAt(hy,i);
void remove(int i)
? elements.size() > 1
elements.removeElementAt(i);
void removeAll()
Row makeCopy()
Row r = new Row(Default.foregroundColor);
* int i = 0; i < elements.size(); i++
getElement(i);
? sy != null
r.insert(new Symbol(sy.c, sy.font, sy.color), i+1);
<----------
? im != null
r.insert(im.makeCopy(), i+1);
r.remove(0);
r.planSize();
<======(
r
)
Row makeCleanCopy()
ALGJAVA 13.07.06
0x0-sümbolit üle ei kanta, muidu == makeCopy
Kasutab: Sketch2Xml.writeRowElements()
Row r = new Row(Default.foregroundColor);
* int i = 0, j = 1; i < elements.size(); i++
getElement(i);
? sy != null
? sy.c != 0
r.insert(new Symbol(sy.c, sy.font, sy.color), j++);
<----------
? im != null
r.insert(im.makeCopy(), j++);
r.remove(0);
r.planSize();
<======(
r
)
void trim()
int j;
int i = 1;
boolean isChanged = false;
<======
getElement(i);
? (sy == null) || !Character.isWhitespace(sy.c)
j = elements.size() - 1;
<======
getElement(j);
? (sy == null) || !Character.isWhitespace(sy.c)
<======
remove(j--); isChanged = true;
<======
remove(i); isChanged = true;
public String toString()
StringBuffer t = new StringBuffer();
* int i = 1; i < elements.size(); i++
getElement(i);
? sy != null
t.append(sy.c);
<======t.toString()
public String toString(Color col)
StringBuffer t = new StringBuffer();
* int i = 1; i < elements.size(); i++
getElement(i);
? sy != null
? sy.color != col
t.append(sy.c);
<======t.toString()
void plan(int x0, int y0)
void planSize()
int h;
prevW = width;
prevH = height;
width = 0;
height = 0;
maxDescent = 0;
* int i = 0; i < elements.size(); i++
getElement(i);
? sy != null
width += sy.width();
int descent = sy.descent();
h = sy.ascent() + descent;
? descent > maxDescent
maxDescent = descent;
<------
? im != null
width += im.width();
h = im.height();
? h > height
height = h;
public void draw(Graphics g)
prevX = x; prevY = y;
prevW = width; prevH = height;
int xx = x;
int yy = y + height - maxDescent;
int n = elements.size();
getElement(0);
JK 09.01.06
? n > 1
sy.draw(g, xx, yy, Default.backgroundColor);
<======
//JK 09.01.06
g.setFont(sy.font);
Character cc = new Character(sy.c);
? n == 1
g.setColor(sy.color);
<======
g.setColor(Default.backgroundColor);
g.drawString(cc.toString(), xx, yy);
xx += sy.width();
* int i = 1; i < n; i++
getElement(i);
? sy != null
sy.draw(g, xx, yy);
JK 09.01.06
//JK 09.01.06
cc = new Character(sy.c);
g.setFont(sy.font);
g.setColor(sy.color);
g.drawString(cc.toString(), xx, yy);
xx += sy.width();
<------
? im != null
im.draw(g, xx, y);
xx += im.width();
<------
public Color isMonochrome()
Color color = ((Symbol)(elements.elementAt(0))).color;
* int j = 1; j < elements.size(); j++
getElement(j);
? sy == null
<==========null
<==========null
<======color
public void invalidate()
stiiliseaded
void toggleColor(int start, int end)
* int i = start; i <= end; i++
getElement(i);
? sy != null
int R = sy.color.getRed() + 43;
int G = sy.color.getGreen() + 161;
int B = sy.color.getBlue() + 83;
sy.color = new Color(R, G, B);
void toggleColor()
toggleColor(0, elements.size()-1);
void setColor(int start, int end, Color col)
* int i = start; i <= end; i++
getElement(i);
? sy != null
sy.color = col;
public void setColor(Color col)
setColor(0, elements.size()-1, col);
void setFont(int start, int end, Font font)
* int i = start; i <= end; i++
getElement(i);
? sy != null
sy.font = font;
planSize();
void setFont(Font font)
setFont(0, elements.size()-1, font);
void setStyle(int start, int end, Color col, Font font)
* int i = start; i <= end; i++
getElement(i);
? sy != null
sy.color = col;
sy.font = font;
planSize();
void setStyle(Color col, Font font)
setStyle(0, elements.size()-1, col, font);
R.USTICH
Row(String s)
int index_elements = 1;
int index_str = 0;
int str_begin = 0;
int str_end = 0;
boolean el0 = false;
int i;
String tmp_s = "";
Color cur_color = new Color(0);
Font cur_font = new Font("TimesRoman",0,10);
elements = new Vector();
* ;true;
str_begin= s.indexOf("
? str_begin == -1
? el0 == false
insert(new Symbol(Default.leadingChar,Default.font,Default.foregroundColor), 0);
el0=true;
<======
index_str = s.indexOf(">",str_begin);
str_begin = s.indexOf("\"#",str_begin) +2;
str_end = s.indexOf("\"",str_begin);
cur_color = HTMLStringtoColor(s.substring(str_begin,str_end));
str_begin = s.indexOf("\"", str_end+1)+1;
str_end = s.indexOf("\"",str_begin + 1);
cur_font = HTMLStringtoFont(s.substring(str_begin, str_end));
? el0 == false
insert(new Symbol(Default.leadingChar,cur_font,cur_color), 0);
el0=true;
str_begin = index_str;
str_end = s.indexOf("<", str_begin);
? str_end == -1
str_end = s.length();
tmp_s = s.substring(str_begin+1, str_end);
tmp_s = Replace(tmp_s,"<","<");
tmp_s = Replace(tmp_s,">",">");
* i=0;i
insert (new Symbol(tmp_s.charAt(i),cur_font,cur_color),index_elements++);
str_begin = str_end+1;
? str_begin>=s.length()
<======
width = 0; height = 0;
x = -1;
y = -1;
width = -1;
height = -1;
planSize();
String Replace(String target,String s1,String s2)
int i=0;
int str_begin=0;
int str_end=0;
String tmp_str = "";
String ret = "";
str_end = target.indexOf(s1, str_begin);
? str_end == -1
<==========ret + target.substring(str_begin,target.length())
ret = ret + target.substring(str_begin, str_end)+s2;
str_begin = str_end + s1.length();
public String ColortoHTMLString(Color c)
String r;
String g;
String b;
Integer tmp = new Integer(0);
r=tmp.toHexString(c.getRed());
g =tmp.toHexString(c.getGreen());
b =tmp.toHexString(c.getBlue());
? r.length()==1
r = "0"+r;
? g.length()==1
g = "0"+g;
? b.length()==1
b = "0"+b;
<======"\"#"+ r + g+ b +"\" "
public String FonttoHTMLString(Font f)
<======"\""+f.getName()+"\""
public Color HTMLStringtoColor(String s)
Integer tmp = new Integer(0);
<======new Color(tmp.parseInt(s.substring(0,2),16),
tmp.parseInt(s.substring(2,4),16),tmp.parseInt(s.substring(4,6),16))
public Font HTMLStringtoFont(String s)
String tmp_str;
* int i=0; i
? s.equals(AmFont.font[i].getName())
<==========AmFont.font[i]
<======Default.font
public String toHTMLString()
StringBuffer t = new StringBuffer();
int i;
boolean opened = false;
String cur_color="" ;
String cur_font="" ;
String ret;
? elements.size()<=1
<======""
* i = 1; i < elements.size(); i++
getElement(i);
? sy != null
? opened == false
t.append("");
opened = true;
? sy.c == '<'
t.append("<");
<======
? sy.c == '>'
t.append(">");
<======
cur_color = ColortoHTMLString(sy.color);
cur_font = FonttoHTMLString(sy.font);
<----------
? cur_color.compareTo(ColortoHTMLString(sy.color))!=0 || cur_font.compareTo(FonttoHTMLString(sy.font))!=0
t.append("");
t.append("");
cur_color = ColortoHTMLString(sy.color);
cur_font = FonttoHTMLString(sy.font);
? sy.c == '<'
t.append("<");
<----------
? sy.c == '>'
t.append(">");
<----------
t.append("");
ret = t.toString();
<======ret
public void tag2Img()
eeldab, et ei ole veel pilte ja hüperelemente
String r=toString();
//Row rida=this;
JK
Row rida=makeCopy();
JK
Color col;
=rida.sy.color; JK
//rida=new Row(r,col);
JK
removeAll();
//rida.removeAll();
JK
int len=r.length();
int co=1;
* int i=0;i
//Symbol sym=new Symbol(r.charAt(i),col);
JK
rida.getElement(i);
JK
Symbol sym = rida.sy;
JK
? r.charAt(i)=='<'
? r.charAt(i+1)=='I'
? (r.substring(i+2,i+10).compareTo("MG SCR= ")==0)
int puk=r.indexOf('>',i);
String nimi=r.substring(i+10,puk);
Am.pictureBoard.processIMGs(this,co,nimi);
co++;
i=puk;
<======
<======
<------
planSize();
<======
public void img2tag()
String str="";
int j=0;
String sss=this.toString();
int pik=sss.length();
* int i=1;i
Object o=this.element(i);
? o instanceof AmImage
AmImage imi=(AmImage)o;
String st="";
str=str+st;
<----------
? j
char cc=sss.charAt(j);
j++;
str=str+cc;
Row rida=new Row(str,Default.foregroundColor);
removeAll();
* int i = 1; i < rida.elements.size(); i++
elements.addElement(rida.elements.elementAt(i));
planSize();
<======