⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spmonth.java

📁 粉红知己Java源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SPMonth.java

package ladyconf;

import com.siemens.mp.game.ExtendedImage;
import java.util.Calendar;
import java.util.Date;
import javax.microedition.lcdui.*;

// Referenced classes of package ladyconf:
//            SPKernel

public class SPMonth extends Canvas
    implements CommandListener
{

    public SPMonth(SPKernel spk)
    {
        ShowLine = 4;
        OKCmd = new Command("\u786E\u5B9A", 4, 0);
        DetailCmd = new Command("\u56FE\u4F8B", 4, 0);
        BackCmd = new Command("\u8FD4\u56DE", 4, 1);
        ExitCmd = new Command("\u9000\u51FA", 7, 2);
        month = Calendar.getInstance();
        ShowLine = (getHeight() - 12) / 12;
        ExScreenImg = new ExtendedImage(Image.createImage(104, getHeight()));
        Exg = ExScreenImg.getImage().getGraphics();
        pKernel = spk;
        pInput = new Form("\u5B89\u5168\u671F\u8BA1\u7B97");
        lastdate = new DateField("\u4E0A\u6B21\u6708\u7ECF\u8D77\u59CB\u65E5:", 1);
        period = new TextField("\u6708\u7ECF\u5468\u671F", "28", 2, 2);
        lastdate.setDate(new Date(System.currentTimeMillis()));
        pInput.append(lastdate);
        pInput.append(period);
        pInput.addCommand(OKCmd);
        pInput.addCommand(BackCmd);
        pInput.addCommand(ExitCmd);
        addCommand(DetailCmd);
        addCommand(BackCmd);
        addCommand(ExitCmd);
    }

    public void activate(Display disp)
    {
        display = disp;
        pInput.setCommandListener(this);
        display.setCurrent(pInput);
    }

    private void show()
    {
        setCommandListener(this);
        display.setCurrent(this);
    }

    public void setDate(Date sdate, int period)
    {
        month.setTime(sdate);
        month.set(10, 0);
        month.set(12, 0);
        month.set(13, 0);
        PeriodDate = month.getTime().getTime();
        thePeriod = period;
        setYear = month.get(1);
        setMonth = month.get(2) + 1;
        setShowData(setYear, setMonth);
        showfirst = true;
    }

    private void setShowData(int yy, int mm)
    {
        month.set(1, yy);
        month.set(2, mm - 1);
        month.set(5, 1);
        thisYear = yy;
        thisMonth = mm;
        firstWeek = getWeek(month.get(7));
        if(thisMonth == 12)
        {
            month.set(1, thisYear + 1);
            month.set(2, 0);
        } else
        {
            month.set(2, thisMonth);
        }
        long msdate = month.getTime().getTime();
        msdate -= 0x5265c00;
        month.setTime(new Date(msdate));
        DateCount = month.get(5);
        lineInfo[1] = 8 - firstWeek;
        lineInfo[2] = lineInfo[1] + 7;
        lineInfo[3] = lineInfo[2] + 7;
        lineInfo[4] = lineInfo[3] + 7;
        lineInfo[5] = lineInfo[4] + 7;
        WeekCount = 6;
        if(lineInfo[5] > DateCount)
            WeekCount = 5;
        if(lineInfo[4] > DateCount)
            WeekCount = 4;
        firstLine = 0;
    }

    protected void keyPressed(int keycode)
    {
        if(type == 1)
        {
            type = 0;
            addCommand(DetailCmd);
            addCommand(BackCmd);
            addCommand(ExitCmd);
            DrawCalendar();
            redraw();
            return;
        }
        if(keycode == -1 || keycode == 53)
        {
            type = 1;
            removeCommand(BackCmd);
            removeCommand(DetailCmd);
            removeCommand(ExitCmd);
            DrawDetail();
            redraw();
        } else
        if(keycode == -59 || keycode == 50)
        {
            if(firstLine > 0)
            {
                firstLine--;
                DrawCalendar();
                redraw();
            }
        } else
        if(keycode == -60 || keycode == 56)
        {
            if(firstLine < WeekCount - ShowLine)
            {
                firstLine++;
                DrawCalendar();
                redraw();
            }
        } else
        if(keycode == -61 || keycode == 52)
        {
            if(!showfirst)
            {
                setShowData(setYear, setMonth);
                showfirst = true;
                DrawCalendar();
                redraw();
            }
        } else
        if(keycode == -62 || keycode == 54)
        {
            if(showfirst)
            {
                if(setMonth + 1 > 12)
                    setShowData(setYear + 1, 1);
                else
                    setShowData(setYear, setMonth + 1);
                showfirst = false;
                DrawCalendar();
                redraw();
            }
        } else
        if(keycode == -12)
            pKernel.ShowSelect();
    }

    public void commandAction(Command cmd, Displayable obj)
    {
        if(cmd == OKCmd)
        {
            setDate(lastdate.getDate(), Integer.parseInt(period.getString()));
            show();
        } else
        if(cmd == DetailCmd)
            keyPressed(-1);
        else
        if(cmd == BackCmd)
            keyPressed(-12);
        else
        if(cmd == ExitCmd)
            pKernel.Exit();
    }

    protected void paint(Graphics grap)
    {
        if(type == 0)
            DrawCalendar();
        redraw();
    }

    private void DrawCalendar()
    {
        ExScreenImg.clear((byte)0);
        Exg.setFont(SysFont);
        Exg.drawString("\u65E5", 6, 0, 17);
        Exg.drawString("\u516D", 90, 0, 17);
        Exg.setFont(BoldFont);
        String tmstr = String.valueOf(String.valueOf((new StringBuffer("(")).append(thisYear).append(".").append(thisMonth).append(")")));
        if(showfirst)
            tmstr = String.valueOf(String.valueOf(tmstr)).concat(" >");
        else
            tmstr = "< ".concat(String.valueOf(String.valueOf(tmstr)));
        Exg.drawString(tmstr, 49, 0, 17);
        Exg.drawLine(0, 13, 101, 13);
        int factshow = ShowLine;
        if(WeekCount < ShowLine)
            factshow = WeekCount;
label0:
        for(int j = 0; j < factshow; j++)
        {
            int i = 0;
            int k = 0;
            do
            {
                if(i >= 7)
                    continue label0;
                if(j + firstLine == 0 && i == 0)
                    i = firstWeek;
                int day = lineInfo[firstLine + j] + k;
                if(day > DateCount)
                    continue label0;
                month.set(5, day);
                int tp = calcDate(month.getTime().getTime());
                Exg.setColor(0);
                switch(tp)
                {
                case 0: // '\0'
                    Exg.setFont(SmallFont);
                    break;

                case 1: // '\001'
                    Exg.setFont(SmallBoldFont);
                    break;

                case 2: // '\002'
                    Exg.setFont(SmallBoldFont);
                    Exg.fillRect(i * 14, 16 + j * 12, 13, 11);
                    Exg.setColor(0xffffff);
                    break;
                }
                Exg.drawString(Integer.toString(day), 6 + i * 14, 17 + j * 12, 17);
                if(tp == 1)
                    Exg.drawLine(i * 14 + 1, 26 + j * 12, i * 14 + 11, 26 + j * 12);
                i++;
                k++;
            } while(true);
        }

        Exg.setColor(0xffffff);
        Exg.fillRect(98, 16, 3, ShowLine * 12 - 2);
        Exg.setColor(0);
        Exg.drawRect(98, 16, 2, ShowLine * 12 - 2);
        int tHi = (factshow * (ShowLine * 12 - 2)) / WeekCount;
        Exg.fillRect(99, 17 + (firstLine * (ShowLine * 12 - 2)) / WeekCount, 1, tHi);
    }

    private void DrawDetail()
    {
        Exg.setColor(0xffffff);
        Exg.fillRect(5, 9, 90, 48);
        Exg.setColor(0);
        Exg.drawRect(5, 9, 90, 48);
        Exg.setFont(SmallBoldFont);
        Exg.drawString("00", 10, 15, 20);
        Exg.drawLine(11, 24, 21, 24);
        Exg.fillRect(10, 29, 13, 11);
        Exg.setColor(0xffffff);
        Exg.drawString("00", 10, 30, 20);
        Exg.setColor(0);
        Exg.setFont(SmallFont);
        Exg.drawString("00", 10, 44, 20);
        Exg.setFont(SysFont);
        Exg.drawString("\u6708\u7ECF\u671F", 24, 13, 20);
        Exg.drawString("\u6392\u5375\u671F(\u5371\u9669)", 24, 28, 20);
        Exg.drawString("\u7406\u8BBA\u5B89\u5168\u671F", 24, 42, 20);
    }

    private void redraw()
    {
        ExScreenImg.blitToScreen(0, 0);
    }

    private int calcDate(long msday)
    {
        int d = ((int)((msday - PeriodDate) / (long)0x5265c00) + 2 * thePeriod) % thePeriod;
        if(d < 5)
            return 1;
        return d <= thePeriod - 20 || d >= thePeriod - 9 ? 0 : 2;
    }

    private int getWeek(int week)
    {
        switch(week)
        {
        case 1: // '\001'
            return 0;

        case 2: // '\002'
            return 1;

        case 3: // '\003'
            return 2;

        case 4: // '\004'
            return 3;

        case 5: // '\005'
            return 4;

        case 6: // '\006'
            return 5;

        case 7: // '\007'
            return 6;
        }
        return 0;
    }

    private int ShowLine;
    private SPKernel pKernel;
    private Display display;
    private ExtendedImage ExScreenImg;
    private Graphics Exg;
    private Command OKCmd;
    private Command DetailCmd;
    private Command BackCmd;
    private Command ExitCmd;
    public static Font SysFont = Font.getFont(0, 0, 0);
    public static Font BoldFont = Font.getFont(0, 1, 0);
    public static Font SmallFont = Font.getFont(0, 0, 8);
    public static Font SmallBoldFont = Font.getFont(0, 1, 8);
    private Calendar month;
    private long PeriodDate;
    private Form pInput;
    private DateField lastdate;
    private TextField period;
    private int lineInfo[] = {
        1, 0, 0, 0, 0, 0
    };
    private int setYear;
    private int setMonth;
    private int thisYear;
    private int thisMonth;
    private int firstWeek;
    private int DateCount;
    private int WeekCount;
    private int firstLine;
    private int thePeriod;
    private int type;
    private boolean showfirst;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -