home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Scrollbar;
- import java.util.Vector;
-
- class OCmltext extends Panel {
- public int appWidth;
- public int appHeight;
- public Color bgColor = new Color(153, 153, 153);
- private Image off;
- private Graphics g_off;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_0;
- // $FF: renamed from: ds java.awt.Dimension
- private Dimension field_1;
- private int appx;
- private int appy;
- private boolean paint_called;
- private boolean first_run = true;
- private String[] def_pn;
- private String[] def_pv;
- private String[] spe_pn;
- private Vector spe_pv;
- private int desc_index;
- private String[] m_desc;
- private int[] m_align;
- private int m_def_align;
- private Color[] m_textcolor;
- private Color m_def_textcolor;
- private Font[] m_cur_font;
- private Font m_font;
- private int m_xoffset;
- private Color m_bgcolor;
- int num_descrips;
- int sb_width;
- // $FF: renamed from: sb java.awt.Scrollbar
- Scrollbar field_2;
- Scrollbar hsb;
- int scroll_y;
- int scroll_x;
- int sb_linedist;
- int hsb_linedist;
- boolean first_sb_run;
- boolean first_hsb_run;
- boolean use_sb;
- boolean use_hsb;
- int last_scroll_y;
- int last_scroll_x;
- int sEdge;
- int sbImgWidth;
- int sbImgHeight;
- int offimgx;
- int offimgy;
-
- public void updateDisplay(int desci) {
- this.desc_index = desci;
- this.centerAppArea();
- }
-
- private void initDefault() {
- String param = this.getParameterDefault("font");
- if (param != null) {
- this.m_font = ocfontc.getFontSD(param, ",");
- } else {
- this.m_font = new Font("Helvetica", 0, 12);
- }
-
- param = this.getParameterDefault("textcolor");
- if (param != null) {
- this.m_def_textcolor = occcolor.ConvertColor(param);
- }
-
- param = this.getParameterDefault("bgcolor");
- if (param != null) {
- this.m_bgcolor = occcolor.ConvertColor(param);
- }
-
- param = this.getParameterDefault("lrmargins");
- if (param != null) {
- this.m_xoffset = Integer.parseInt(param);
- }
-
- param = this.getParameterDefault("halign");
- if (param != null) {
- this.m_def_align = Integer.parseInt(param);
- }
-
- }
-
- public void reshape(int x, int y, int width, int height) {
- if (width * height > 0) {
- this.field_1 = new Dimension(width, height);
- this.centerAppArea();
- super.reshape(x, y, width, height);
- }
- }
-
- private void drawMessage() {
- if (!this.first_run) {
- this.g_off.setFont(this.m_cur_font[this.desc_index]);
- this.field_0 = ((Component)this).getFontMetrics(this.m_cur_font[this.desc_index]);
- int mx = this.sbImgWidth / 2 - this.field_0.stringWidth(this.m_desc[this.desc_index]) / 2;
- int my = this.sbImgHeight / 2 + (this.field_0.getAscent() + this.field_0.getLeading()) / 2;
- this.g_off.setColor(this.m_textcolor[this.desc_index]);
- this.g_off.drawString(this.m_desc[this.desc_index], mx, my);
- this.g_off = this.off.getGraphics();
- this.paintIt();
- }
-
- }
-
- private void centerAppArea() {
- int sbx = 0;
- int sby = 0;
- if (this.appHeight > this.field_1.height) {
- this.use_sb = true;
- sby = this.sb_width;
- } else {
- this.use_sb = false;
- }
-
- if (this.appWidth > this.field_1.width) {
- this.use_hsb = true;
- sbx = this.sb_width;
- } else {
- this.use_hsb = false;
- }
-
- if (this.use_hsb) {
- this.sbImgWidth = this.appWidth + this.sEdge * 2;
- } else {
- this.sbImgWidth = this.appWidth;
- }
-
- if (this.use_sb) {
- this.sbImgHeight = this.appHeight + this.sEdge * 2;
- } else {
- this.sbImgHeight = this.appHeight;
- }
-
- this.offimgx = (this.field_1.width - (this.sbImgWidth - sbx)) / 2;
- this.offimgy = (this.field_1.height - (this.sbImgHeight - sby)) / 2;
- this.scroll_y = this.offimgy;
- this.scroll_x = this.offimgx;
- if (this.use_sb) {
- this.scroll_y = this.last_scroll_y;
- }
-
- if (this.use_hsb) {
- this.scroll_x = this.last_scroll_x;
- }
-
- this.first_run = true;
- this.paintIt();
- }
-
- private void paintIt() {
- if (this.paint_called) {
- Graphics g = ((Component)this).getGraphics();
- if (this.first_run) {
- ((Component)this).setBackground(this.bgColor);
- if (this.field_1.width * this.field_1.height <= 0) {
- return;
- }
-
- this.off = ((Component)this).createImage(this.sbImgWidth, this.sbImgHeight);
- this.g_off = this.off.getGraphics();
- this.g_off.setColor(this.m_bgcolor);
- this.g_off.fillRect(this.sEdge, this.sEdge, this.appWidth, this.appHeight);
- this.first_run = false;
- this.drawMessage();
- if (this.first_sb_run) {
- if (this.use_sb) {
- this.field_2 = new Scrollbar();
- if (this.use_sb && this.use_hsb) {
- this.field_2.reshape(this.field_1.width - this.sb_width, 0, this.sb_width, this.field_1.height - this.sb_width);
- } else {
- this.field_2.reshape(this.field_1.width - this.sb_width, 0, this.sb_width, this.field_1.height);
- }
-
- this.field_2.setBackground(Color.gray);
- ((Container)this).add(this.field_2);
- this.first_sb_run = false;
- }
- } else if (!this.use_sb) {
- ((Container)this).remove(this.field_2);
- this.field_2 = null;
- this.first_sb_run = true;
- } else if (this.use_sb && this.use_hsb) {
- this.field_2.reshape(this.field_1.width - this.sb_width, 0, this.sb_width, this.field_1.height - this.sb_width);
- } else {
- this.field_2.reshape(this.field_1.width - this.sb_width, 0, this.sb_width, this.field_1.height);
- }
-
- if (this.use_sb) {
- this.field_2.setValues(this.field_2.getValue(), 1, 0, this.sbImgHeight - this.field_1.height);
- }
-
- if (this.first_hsb_run) {
- if (this.use_hsb) {
- this.hsb = new Scrollbar(0);
- if (this.use_sb && this.use_hsb) {
- this.hsb.reshape(0, this.field_1.height - this.sb_width, this.field_1.width - this.sb_width, this.sb_width);
- } else {
- this.hsb.reshape(0, this.field_1.height - this.sb_width, this.field_1.width, this.sb_width);
- }
-
- this.hsb.setBackground(Color.gray);
- ((Container)this).add(this.hsb);
- this.first_hsb_run = false;
- }
- } else if (!this.use_hsb) {
- ((Container)this).remove(this.hsb);
- this.hsb = null;
- this.first_hsb_run = true;
- } else if (this.use_sb && this.use_hsb) {
- this.hsb.reshape(0, this.field_1.height - this.sb_width, this.field_1.width - this.sb_width, this.sb_width);
- } else {
- this.hsb.reshape(0, this.field_1.height - this.sb_width, this.field_1.width, this.sb_width);
- }
-
- if (this.use_hsb) {
- this.hsb.setValues(this.hsb.getValue(), 1, 0, this.sbImgWidth - this.field_1.width);
- return;
- }
- } else {
- g.drawImage(this.off, this.scroll_x, this.scroll_y, this);
- if (this.use_sb && this.use_hsb) {
- g.setColor(Color.lightGray);
- } else {
- g.setColor(new Color(153, 153, 153));
- }
-
- g.fillRect(this.field_1.width - this.sb_width, this.field_1.height - this.sb_width, this.sb_width, this.sb_width);
- }
-
- }
- }
-
- private String getParameterDefault(String param) {
- for(int i = 0; i < this.def_pn.length; ++i) {
- if (this.def_pn[i].equals(param)) {
- return this.def_pv[i];
- }
- }
-
- return null;
- }
-
- public void initSpecifics() {
- int i = 0;
- this.num_descrips = this.spe_pv.size();
- this.m_cur_font = new Font[this.num_descrips];
- this.m_textcolor = new Color[this.num_descrips];
- this.m_desc = new String[this.num_descrips];
- this.m_align = new int[this.num_descrips];
-
- for(int var7 = 0; var7 < this.num_descrips; ++var7) {
- String param = this.getParameterSpecific("desc", var7);
- if (param != null) {
- this.m_desc[var7] = param;
- } else {
- this.m_desc[var7] = " ";
- }
-
- param = this.getParameterSpecific("font", var7);
- if (param != null) {
- this.m_cur_font[var7] = ocfontc.getFontSD(param, ",");
- } else {
- this.m_cur_font[var7] = this.m_font;
- }
-
- param = this.getParameterSpecific("align", var7);
- if (param != null) {
- this.m_align[var7] = Integer.parseInt(param);
- } else {
- this.m_align[var7] = this.m_def_align;
- }
-
- param = this.getParameterSpecific("textcolor", var7);
- if (param != null) {
- this.m_textcolor[var7] = occcolor.ConvertColor(param);
- } else {
- this.m_textcolor[var7] = this.m_def_textcolor;
- }
- }
-
- }
-
- public void resize(Dimension d) {
- if (d.width * d.height > 0) {
- this.field_1 = d;
- this.centerAppArea();
- super.resize(d);
- }
- }
-
- public void resize(int width, int height) {
- if (width * height > 0) {
- this.field_1 = new Dimension(width, height);
- this.centerAppArea();
- super.resize(width, height);
- }
- }
-
- public void addSpecifics(String[] pn, Vector pv) {
- this.spe_pn = pn;
- this.spe_pv = pv;
- this.initSpecifics();
- }
-
- public void setAppDimensions(int w, int h) {
- if (w != this.appWidth || h != this.appHeight) {
- this.appWidth = w;
- this.appHeight = h;
- Graphics g = ((Component)this).getGraphics();
- ((Component)this).setBackground(this.bgColor);
- ((Component)this).repaint();
- }
-
- this.appWidth = w;
- this.appHeight = h;
- this.centerAppArea();
- }
-
- OCmltext() {
- this.m_def_textcolor = Color.black;
- this.m_font = new Font("Helvetica", 0, 12);
- this.m_xoffset = 4;
- this.m_bgcolor = Color.white;
- this.sb_width = 12;
- this.sb_linedist = 1;
- this.hsb_linedist = 1;
- this.first_sb_run = true;
- this.first_hsb_run = true;
- this.sEdge = 5;
- ((Container)this).setLayout((LayoutManager)null);
- }
-
- public void addDefaults(String[] pn, String[] pv) {
- this.def_pn = pn;
- this.def_pv = pv;
- this.initDefault();
- }
-
- private String getParameterSpecific(String param, int index) {
- for(int i = 0; i < this.spe_pn.length; ++i) {
- if (this.spe_pn[i].equals(param)) {
- String s = ((String[])this.spe_pv.elementAt(index))[i];
- if (s != null && !s.equals("") && !s.equalsIgnoreCase("<default>")) {
- return s;
- }
-
- return null;
- }
- }
-
- return null;
- }
-
- public void paint(Graphics g) {
- this.paint_called = true;
- this.paintIt();
- }
-
- public boolean handleEvent(Event e) {
- boolean go = false;
- boolean hgo = false;
- if (e.target == this.field_2) {
- if (e.id != 602 && e.id != 601 && e.id != 605) {
- if (e.id == 604 || e.id == 603) {
- this.scroll_y = -(this.field_2.getValue() * this.sb_linedist);
- this.field_2.setValue(this.field_2.getValue());
- go = true;
- }
- } else {
- this.scroll_y = -(this.field_2.getValue() * this.sb_linedist);
- this.field_2.setValue(this.field_2.getValue());
- go = true;
- }
-
- if (go) {
- if (this.scroll_y >= 0) {
- this.scroll_y = 0;
- } else if (this.scroll_y + this.sbImgHeight < this.field_1.height) {
- this.scroll_y = -this.sbImgHeight + this.field_1.height;
- }
-
- this.last_scroll_y = this.scroll_y;
- this.paintIt();
- go = false;
- }
-
- return true;
- } else if (e.target != this.hsb) {
- return super.handleEvent(e);
- } else {
- if (e.id != 602 && e.id != 601 && e.id != 605) {
- if (e.id == 604 || e.id == 603) {
- this.scroll_x = -(this.hsb.getValue() * this.hsb_linedist);
- this.hsb.setValue(this.hsb.getValue());
- hgo = true;
- }
- } else {
- this.scroll_x = -(this.hsb.getValue() * this.hsb_linedist);
- this.hsb.setValue(this.hsb.getValue());
- hgo = true;
- }
-
- if (hgo) {
- if (this.scroll_x >= 0) {
- this.scroll_x = 0;
- } else if (this.scroll_x + this.sbImgWidth < this.field_1.width) {
- this.scroll_x = -this.sbImgWidth + this.field_1.width;
- }
-
- this.last_scroll_x = this.scroll_x;
- this.paintIt();
- hgo = false;
- }
-
- return true;
- }
- }
- }
-