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

📄 oneloc.java

📁 j2me写的google地图
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 2008-6-16 11:21:14
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   OneLoc.java

package com.eightmotions.map;

import com.eightmotions.util.*;
import henson.midp.Float;
import java.io.InputStream;
import java.util.Hashtable;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.*;

// Referenced classes of package com.eightmotions.map:
//            MapCanvas, OneLocListener

public class OneLoc
    implements Runnable
{

    public OneLoc()
    {
        m_widthB = 90;
        m_heightB = 80;
        m_offY = 15;
        m_offX = 30;
        name = "";
        description = "";
        phoneNum = null;
        address = "";
        iconName = null;
        iconImage = null;
        imageName = null;
        m_theListener = null;
        zoom = 1;
        URL = null;
        isModeSat = false;
        ima_offx = 0;
        ima_offy = 0;
        m_category = 0;
        m_type = 1;
        m_col = 0xff8080;
        m_colForeground = 0xffffff;
        isStarted = false;
        hash = null;
    }

    public OneLoc(String name, Float lon, Float lat, int preferredZoom, boolean isModeSat)
    {
        m_widthB = 90;
        m_heightB = 80;
        m_offY = 15;
        m_offX = 30;
        this.name = "";
        description = "";
        phoneNum = null;
        address = "";
        iconName = null;
        iconImage = null;
        imageName = null;
        m_theListener = null;
        zoom = 1;
        URL = null;
        this.isModeSat = false;
        ima_offx = 0;
        ima_offy = 0;
        m_category = 0;
        m_type = 1;
        m_col = 0xff8080;
        m_colForeground = 0xffffff;
        isStarted = false;
        hash = null;
        init(name, lon, lat, preferredZoom, isModeSat);
    }

    public OneLoc(Float lon, Float lat)
    {
        m_widthB = 90;
        m_heightB = 80;
        m_offY = 15;
        m_offX = 30;
        name = "";
        description = "";
        phoneNum = null;
        address = "";
        iconName = null;
        iconImage = null;
        imageName = null;
        m_theListener = null;
        zoom = 1;
        URL = null;
        isModeSat = false;
        ima_offx = 0;
        ima_offy = 0;
        m_category = 0;
        m_type = 1;
        m_col = 0xff8080;
        m_colForeground = 0xffffff;
        isStarted = false;
        hash = null;
        m_lon = lon;
        m_lat = lat;
        validate();
    }

    public void init(String name, Float lon, Float lat, int preferredZoom, boolean isModeSat)
    {
        this.name = name;
        m_lon = lon;
        m_lat = lat;
        validate();
        zoom = preferredZoom;
        this.isModeSat = isModeSat;
    }

    public int getZoom()
    {
        return zoom;
    }

    public int distFrom(int inpx, int inpy, int inzoom)
    {
        return distFrom(px, py, inpx, inpy, inzoom);
    }

    public static int distFrom(int lp1x, int lp1y, int inpx, int inpy, int inzoom)
    {
        long dx = (lp1x - inpx) / (1 << inzoom);
        long dy = (lp1y - inpy) / (1 << inzoom);
        Float f = new Float(dx * dx + dy * dy);
        int res = (int)Float.sqrt(f).toLong();
        return res;
    }

    public void paint(Graphics g, MapCanvas m)
    {
        paint(g, m.px, m.py, m.offx, m.offy, m.width, m.height, m.getZoom());
    }

    public void paint(Graphics g, int inpx, int inpy, int offx, int offy, int w, int h, 
            int zoom)
    {
        if(m_type == 2)
            return;
        int x = offx + w / 2 + (px - inpx) / (1 << zoom);
        int y = offy + h / 2 + (py - inpy) / (1 << zoom);
        if(x > -m_widthB && y > -m_heightB && x < w + offx && y < h + offy)
            if(iconImage == null)
            {
                int dx = x - w / 2;
                if(dx < 0)
                    dx = -dx;
                int dy = y - h / 2;
                if(dy < 0)
                    dy = -dy;
                g.setColor(m_col);
                switch(m_type)
                {
                case 0: // '\0'
                case 2: // '\002'
                default:
                    g.fillRoundRect(x + 5, y - 25, 12, 12, 9, 9);
                    g.setColor(0);
                    g.drawRoundRect(x + 5, y - 25, 12, 12, 9, 9);
                    g.setColor(m_col);
                    g.fillTriangle(x, y, x + 11, y - 13, x + 6, y - 17);
                    g.setColor(0);
                    g.drawLine(x, y, x + 11, y - 13);
                    g.drawLine(x, y, x + 6, y - 17);
                    break;

                case 1: // '\001'
                    g.fillArc(x + 10, y - 16, 8, 8, 0, 360);
                    g.setColor(0);
                    g.drawLine(x, y, x + 10, y - 10);
                    g.drawArc(x + 10, y - 16, 7, 7, 0, 360);
                    break;

                case 3: // '\003'
                    g.fillTriangle(x - 5, y, x, y - 5, x, y + 5);
                    g.fillTriangle(x + 5, y, x, y - 5, x, y + 5);
                    g.setColor(0);
                    g.drawLine(x - 5, y, x, y - 5);
                    g.drawLine(x, y - 5, x + 5, y);
                    g.drawLine(x + 5, y, x, y + 5);
                    g.drawLine(x, y + 5, x - 5, y);
                    break;

                case 4: // '\004'
                    g.fillArc(x - 5, y - 5, 10, 10, 0, 360);
                    g.setColor(0);
                    g.drawArc(x - 5, y - 5, 10, 10, 0, 360);
                    break;
                }
            } else
            if(m_type != 5)
            {
                g.setColor(m_colForeground);
                g.fillRoundRect(x - iconImage.getWidth() / 2 - 2, y - 10 - (iconImage.getHeight() + 2), iconImage.getWidth() + 4, iconImage.getHeight() + 4, 6, 6);
                g.fillTriangle(x, y, x + 11, y - 13, x + 6, y - 17);
                g.drawImage(iconImage, x - iconImage.getWidth() / 2, y - 10, 36);
            } else
            {
                g.drawImage(iconImage, x + ima_offx, y + ima_offy, 36);
            }
        if(iconImage == null && iconName != null && !isStarted)
        {
            Thread t = new Thread(this);
            t.start();
        }
    }

    public void setListener(OneLocListener inListener)
    {
        m_theListener = inListener;
    }

    public void fireLoaded()
    {
        if(m_theListener != null)
            m_theListener.iconDownloaded(this);
    }

    synchronized int getNbThreads()
    {
        return nbThreads;
    }

    synchronized int incNbThreads()
    {
        return nbThreads++;
    }

    synchronized int decNbThreads()
    {
        return nbThreads--;
    }

    public void setIconImage(Image icon, int offX, int offY)
    {
        m_type = 5;
        iconImage = icon;
        ima_offx = offX;
        ima_offy = offY;
    }

    public void paintFull(Graphics g, MapCanvas map)
    {
        paintFull(g, map.px, map.py, map.offx, map.offy, map.width, map.height, map.getZoom());
    }

    public void paintFull(Graphics g, int inpx, int inpy, int offx, int offy, int w, int h, 
            int zoom)
    {
        int x = offx + w / 2 + (px - inpx) / (1 << zoom);
        int y = offy + h / 2 + (py - inpy) / (1 << zoom);
        int dx = x - w / 2;
        if(dx < 0)
            dx = -dx;
        int dy = y - h / 2;
        if(dy < 0)
            dy = -dy;
        g.setColor(0xff8080);
        g.setColor(0xffffff);
        int saveY = m_offY;
        g.setFont(UtilMidp.m_smallFont);
        int stepy = g.getFont().getHeight();
        if(description.equals("") && address.equals("") && name.equals(""))
        {
            if(iconImage != null)
            {
                m_offY = iconImage.getHeight() - ima_offy;
                m_offX += ima_offx;

⌨️ 快捷键说明

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