Package com.mapmidlet.options

Examples of com.mapmidlet.options.Options


    public static Image downloadAndSaveImage(String url, final String fileUrl) throws IOException {
        Image result = null;
        // long beforeRequest = System.currentTimeMillis();
        HttpConnection http = (HttpConnection) Connector.open(url);
        http.setRequestMethod(HttpConnection.GET);
        Options options = Options.getInstance();

        http
                .setRequestProperty("User-Agent",
                        "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 (.NET CLR 3.5.30729");
View Full Code Here


        return new String(readStream(conn.openDataInputStream()));
    }

    private static byte[] readStream(InputStream inputStream) throws IOException {
        byte[] b = new byte[2048];
        Options options = Options.getInstance();
        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            int c;
            do {
                c = inputStream.read(b);
View Full Code Here

            }
        }
    }

    public static void ensureDirExist(String dir) {
        Options options = Options.getInstance();
        if (!options.useFileApi) {
            return;
        }
        String url = ("file:///" + options.rootName + dir);
        try {
View Full Code Here

        append(resultChoice);
    }

    public void commandAction(Command c, Displayable d) {
        String label = c.getLabel();
        Options options = Options.getInstance();
        if ("Search".equals(label)) {
            resultChoice.deleteAll();
            if (search.getString() != null && search.getString().length() > 0) {

                resultChoice.setLabel("Searching...");
                results = options.geocoder.search(search.getString());

                if (results == null) {
                    resultChoice.setLabel("Search failed.");
                } else if (results.isEmpty()) {
                    resultChoice.setLabel("No results found.");
                } else {
                    resultChoice.setLabel("Search results:");

                    for (int i = 0; i < results.size(); i++) {
                        resultChoice.append(((ScreenMarker) results.elementAt(i)).name, null);
                        resultChoice.setSelectedIndex(i, true);
                    }
                }
            }
        } else if ("Back".equals(label)) {
            Vector newSearchResults = new Vector();

            for (int i = 0; i < resultChoice.size(); i++) {
                if (resultChoice.isSelected(i)) {
                    newSearchResults.addElement(results.elementAt(i));
                }
            }
            options.searchResults = newSearchResults;
            options.refreshMarkers();
            tileCanvas.showSearchResults();
            CloudGps.showTileCanvas();
        }
    }
View Full Code Here

        if (latitude < 0 || longitude < 0 || latitude >= mapSize || longitude >= mapSize) {
            state = STATE_EMPTY;
            return;
        }
        Options options = Options.getInstance();
        if (options.useFileApi && !options.fileReadInSeparateThread) {
            loadFromFile();
        }
        if (image == null) {
            downloader.addTask(new TileLoader(this));
View Full Code Here

        public TileLoader(Tile tile) {
            this.tile = tile;
        }

        public void run() {
            final Options opts = Options.getInstance();
            try {
                if (opts.useFileApi && opts.fileReadInSeparateThread) {
                    tile.loadFromFile();
                }
                if (tile.image == null && opts.onlineMode) {
View Full Code Here

    private static final int INTERNAL_TILESIZE = 256;
    private static double snapx;
    private static double snapy;

    public static void navigate(GpsState gpsState) {
        Options options = Options.getInstance();
        if (options.routingStatus == Options.ROUTING_CALCULATING) {
            return;
        }
        optimizeWaypoints();
        if (gpsState.state >= GpsState.CONNECTED_FIX && options.route != null) {
View Full Code Here

    // 1. determine visible route segments
    // 2. if there are too many route try to remove some by merging
    public static void optimizeWaypoints() {
        TileCanvas canvas = CloudGps.getTileCanvas();
        Options options = Options.getInstance();
        OptimizedRoute or = options.navContext.optimizedRoute;

        if (or != null && or.visibleSegments != null && or.zoom == options.zoom
                && or.horizontalTilesCount == canvas.horizontalTilesCount
                && or.verticalTilesCount == canvas.verticalTilesCount && or.latitude == canvas.latitude
                && or.longitude == canvas.longitude && or.tileSize == canvas.tileSize) {
            return;
        }

        if (or == null) {
            or = new OptimizedRoute();
            options.navContext.optimizedRoute = or;
        }
        or.zoom = options.zoom;
        or.horizontalTilesCount = canvas.horizontalTilesCount;
        or.verticalTilesCount = canvas.verticalTilesCount;
        or.latitude = canvas.latitude;
        or.longitude = canvas.longitude;
        or.tileSize = canvas.tileSize;
        Route r = options.route;
        or.segmentsSCmaxZoom = null;
        or.visibleSegments = null;
        or.visibleSegmentDirections = null;

        Vector visibleSegments = new Vector(100, 200);
        Vector visibleSegmentDirections = new Vector(100, 200);

        int directionIdx = 0;

        if (r != null && r.waypoints.size() > 1) {
            int count = 1;
            if (or.waypointsTC == null || ((TileCoordinate) or.waypointsTC.elementAt(0)).zoom != options.zoom) {
                or.waypointsTC = new Vector(r.waypoints.size());
                for (int i = 0; i < r.waypoints.size(); i++) {
                    or.waypointsTC.addElement(ProjectionTool.toTileCoordinate((WorldCoordinate) r.waypoints
                            .elementAt(i), options.zoom, options.getTileFactory().getTileSize()));
                }
            }

            TileCoordinate t1 = (TileCoordinate) or.waypointsTC.elementAt(0), t2;
            ScreenCoordinate s1 = toSC(t1, or.latitude, or.longitude, or.tileSize), s2;

            int maxX = options.getTileFactory().getTileSize() * or.horizontalTilesCount;
            int maxY = options.getTileFactory().getTileSize() * or.verticalTilesCount;

            for (int i = 1; i < or.waypointsTC.size(); i++) {
                t2 = (TileCoordinate) or.waypointsTC.elementAt(i);
                s2 = toSC(t2, or.latitude, or.longitude, or.tileSize);

View Full Code Here

    }

    private static double snapToRoute(GpsState gpsState) {
        double minDistance = Double.POSITIVE_INFINITY;
        int minIdx = -1;
        Options o = Options.getInstance();
        OptimizedRoute or = o.navContext.optimizedRoute;
        Vector segments = or.visibleSegments;

        double sx = 0, sy = 0;
View Full Code Here

    public void open() throws IOException {

        thread = new Thread(new Runnable() {
            public void run() {
                exit = false;
                Options options = Options.getInstance();
                int tries = 0;
                while (inputStream == null) {
                    try {
                        if (options.replayMode) {
                            inputStream = Connector.openInputStream(options.replayFileName);
View Full Code Here

TOP

Related Classes of com.mapmidlet.options.Options

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.