Exemple #1
0
 public virtual void  paint(Graphics g)
 {
     g.setColor(0xFFFFFF);
     g.fillRect(0, 0, getWidth(), getHeight());
     if (message1 != null)
     {
         g.setColor(0x000000);
         g.drawString(message1, 1, 1, Graphics.TOP | Graphics.LEFT);
         g.drawString(message2, 1, 1 + g.getFont().getHeight(), Graphics.TOP | Graphics.LEFT);
     }
 }
Exemple #2
0
    public static void centerText(javax.microedition.lcdui.Graphics g, string msg, double posY, double centerPos)
    {
        int    sw = g.Font.stringWidth(msg);
        double posX = (centerPos) - sw / 2;
        double dy = 4.0, dx = 0.0;

        g.drawString(msg, (int)JMath.round(posX - dx), (int)JMath.round(posY - dy), g.BOTTOM | g.LEFT);
    }
Exemple #3
0
    public static void centerTextV(javax.microedition.lcdui.Graphics g, string msg, double posX, double centerPos)
    {
        int    sw = g.Font.stringWidth(msg);
        double posY = (centerPos) + sw / 2;
        double dy = 0.0, dx = 0.0;
        Font   oldFont = g.Font;

        g.drawString(msg, (int)posX, (int)posY, g.BOTTOM | g.LEFT);
        g.Font = oldFont;
    }
Exemple #4
0
 public virtual void  paint(Graphics g)
 {
     g.setColor(0xFFFFFF);
     g.fillRect(0, 0, getWidth(), getHeight());
     if (image != null)
     {
         g.drawImage(image, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER);
     }
     g.setColor(0x000000);
     for (int i = 0; i < log.Length; i++)
     {
         if (log[i] != null)
         {
             g.drawString(log[i], 0, i * logFont.getHeight(), Graphics.TOP | Graphics.LEFT);
         }
     }
 }
Exemple #5
0
    internal virtual void drawMessage(javax.microedition.lcdui.Graphics g, int xp, int yp, string[] msg)
    {
        double[] sw = new double[msg.Length];
        for (int i = 0; i < sw.Length; i++)
        {
            sw[i] = g.Font.stringWidth(msg[i]);
        }
        int fh = g.Font.Height;
        int mw = (int)max(sw) + 10, mh = msg.Length * fh + 6;
        int xw = xp < width / 2 ? width - xright - mw : xleft;
        int yw = yp < height / 2 ? height - ybottom - mh : ytop;

        g.Color = WHITE;
        g.fillRect(xw, yw, mw, mh);
        g.Color = BLACK;
        for (int i = 0; i < msg.Length; i++)
        {
            g.drawString(msg[i], xw + 5, yw + (i + 1) * fh + 3, g.BOTTOM | g.LEFT);
        }
    }
Exemple #6
0
    internal virtual void drawOrnaments(javax.microedition.lcdui.Graphics g)
    {
        int    lenMajor = height / 40, i;
        double x = 0, y = 0;
        int    axis_w = width - xleft - xright;
        int    axis_h = height - ytop - ybottom;
        string label;
        int    lenlabel   = g.Font.stringWidth(" 00.00 ");
        int    maxnumtics = axis_w / lenlabel;
        double dX         = (maxx - minx) / ntx;
        double startx     = minx;

        while ((maxx - minx) / dX > maxnumtics)
        {
            dX    *= 2;
            startx = (int)(startx / dX + 0.5) * dX;
            if ((maxx - minx) / dX > maxnumtics)
            {
                dX    *= 2.5;
                startx = (int)(startx / dX + 0.5) * dX;
            }
        }
        if (plotmode == LOGLIN || plotmode == LOGLOG)
        {
            while (Math.Abs((startx / dX) - JMath.round(startx / dX)) > 0.01)
            {
                startx += dX;
            }
            if (dX < 1.0)
            {
                dX = 1.0;
            }
            else if (dX == 2.5)
            {
                dX = 2.0;
            }
            startx = dX * JMath.floor(startx / dX);
        }
        int exponent = Math.Max(decExp(maxx), decExp(minx)) - 1;

        if (Math.Abs(exponent) < 2)
        {
            exponent = 0;
        }
        double scf = JMath.pow(10.0, (double)exponent);

        for (i = 0, x = startx; x <= maxx; i++, x += dX)
        {
            int xworld = getScreenX(x);
            if (xworld < xleft)
            {
                continue;
            }
            g.drawLine(xworld, ytop, xworld, ytop + lenMajor);
            g.drawLine(xworld, height - ybottom - lenMajor, xworld, height - ybottom);
            if ((plotmode == LOGLIN || plotmode == LOGLOG) && (dX < 1.5))
            {
                for (int k = 2; k <= 9; k++)
                {
                    int xk = getScreenX(x + JMath.log((double)k) / JMath.log(10.0));
                    if (xk > xleft && xk < xleft + width)
                    {
                        g.drawLine(xk, ytop, xk, ytop + lenMajor / 2);
                        g.drawLine(xk, height - ybottom - lenMajor / 2, xk, height - ybottom);
                    }
                }
            }
            if (plotmode == LOGLIN || plotmode == LOGLOG)
            {
                label = "10^";
            }
            else
            {
                label = "";
            }
            if (x + dX > maxx && exponent != 0)
            {
                label = "E" + exponent;
            }
            else
            {
                label += fmt.ToString(x / scf);
            }
            centerText(g, label, height - ybottom + 1.5 * g.Font.Height, xworld);
        }
        if (Xlabel_Renamed != null)
        {
            centerText(g, Xlabel_Renamed, height - ybottom + 3 * g.Font.Height, xleft + (width - xleft - xright) / 2);
        }
        if (Tlabel_Renamed != null)
        {
            centerText(g, Tlabel_Renamed, ytop - g.Font.Height / 2, xleft + (width - xleft - xright) / 2);
        }
        if (Ylabel_Renamed != null)
        {
            centerTextV(g, Ylabel_Renamed, g.Font.Height, ytop + (height - ytop - ybottom) / 2);
        }
        int hilabel = g.Font.Height;

        maxnumtics = (int)((axis_h) / (1.5 * hilabel));
        double dY     = (maxy - miny) / nty;
        double starty = miny;

        while ((maxy - miny) / dY > maxnumtics)
        {
            dY    *= 2;
            starty = (int)(starty / dY + 0.5) * dY;
            if ((maxy - miny) / dY > maxnumtics)
            {
                dY    *= 2.5;
                starty = (int)(starty / dY + 0.5) * dY;
            }
        }
        if (plotmode == LINLOG || plotmode == LOGLOG)
        {
            if (dY < 1.0)
            {
                dY = 1.0;
            }
            else if (dY == 2.5)
            {
                dY = 2.0;
            }
            starty = dY * JMath.floor(starty / dY);
        }
        exponent = Math.Max(decExp(maxy), decExp(miny)) - 1;
        if (Math.Abs(exponent) < 2)
        {
            exponent = 0;
        }
        scf = JMath.pow(10.0, (double)exponent);
        for (i = 0, y = starty; y <= maxy; i++, y += dY)
        {
            int yworld = getScreenY(y);
            if (yworld > height - ybottom)
            {
                continue;
            }
            g.drawLine(xleft, yworld, xleft + lenMajor, yworld);
            g.drawLine(xleft + axis_w, yworld, xleft + axis_w - lenMajor, yworld);
            if ((plotmode == LINLOG || plotmode == LOGLOG) && dY < 1.5)
            {
                for (int k = 2; k <= 9; k++)
                {
                    int yk = getScreenY(y + JMath.log((double)k) / JMath.log(10.0));
                    if (yk > ytop && yk < ytop + height)
                    {
                        g.drawLine(xleft, yk, xleft + lenMajor / 2, yk);
                        g.drawLine(xleft + axis_w, yk, xleft + axis_w - lenMajor / 2, yk);
                    }
                }
            }
            if (plotmode == LINLOG || plotmode == LOGLOG)
            {
                label = "10^";
            }
            else
            {
                label = "";
            }
            if (y + dY > maxy && exponent != 0)
            {
                label = "E" + exponent;
            }
            else
            {
                label += fmt.ToString(y / scf);
            }
            g.drawString(label, xleft - g.Font.stringWidth(label) - 3, yworld + hilabel / 2 - 3, g.BOTTOM | g.LEFT);
        }
    }