Package org.codemap

Examples of org.codemap.Location


        });
       
        int badCount = 0;
        for(int x = 0; x < mapInstance.width; x++) {
            for (int y = 0; y < mapInstance.height; y++) {
                Location kdTreeNearest = mapInstance.kdTreeNearest(x, y);
                Location naiveNearest = mapInstance.naiveNearest(x, y);
                if (naiveNearest.equals(kdTreeNearest)) continue;
               
                badCount++;
//                assertEquals(naiveNearest, kdTreeNearest);
            }
        }
View Full Code Here


           // do not add an edge from the node to itself because
           // - the clustering algorithm does not like it
           // - it won't appear on the map anyway as the edge would have a length of 0
           if (childPath.equals(rootPath)) continue;
          
           Location location = locations.get(childPath);
           if (location == null) continue;
          
           Integer weight = locationWeights.get(location);
           if (weight == null) {
               weight = 0;
           }
           weight += 1;
           locationWeights.put(location, weight);
       }
      
       Graph graph = new Graph();
       Location rootLocation = locations.get(rootPath);
       if (rootLocation == null) return;
       Node rootNode = new Node(rootLocation.px, rootLocation.py, 1, rootLocation.getDocument());
       graph.addNode(rootNode);
       graph.setRootNode(rootNode);
      
       for (Location each: locationWeights.keySet()) {
           Integer weight = locationWeights.get(each);
View Full Code Here

        for(Point each: points.keySet()) {
            int x = toMapCoords(each.x);
            int y = toMapCoords(each.y);
            org.eclipse.swt.graphics.Point extent = new org.eclipse.swt.graphics.Point(x, y);
            int fontsize = (points.get(each))/3;
            labels.add(new Label(x-20, y-60, extent, fontsize, each.getDocument(), new Location(each, 0, x, y)));
        }
        labeling = new Labeling(labels);
       
        MapInstance mapInstance = configuration.withSize(mapSize, new MapScheme<Double>() {
            @Override
            public Double forLocation(Point location) {
                // TODO fill in size
                return (double) points.get(location);

            }
        })
       
        DEMAlgorithm algorithm = new DEMAlgorithm();
        algorithm.setMap(mapInstance);
        float[][] DEM = algorithm.call();
       
        ShadeAlgorithm hsa = new ShadeAlgorithm();
        hsa.setMap(mapInstance);
        double[][] shading = hsa.call();
       
        int mapSize = mapInstance.getWidth();
        Device device = Display.getCurrent();
        background = new Image(device, mapSize, mapSize);
        GC gc = new GC(background);
       
        String makeRed = "MapPerProject";
       
        CodemapColors colors = new CodemapColors();
        colors.setColor(makeRed, new MColor(255, 0, 0));
        Iterable<Location> locations = mapInstance.locations();
        ColorBrewer colorBrewer = new ColorBrewer();
        for (Location location : locations) {
            MColor color = colorBrewer.forPackage(location.getDocument());
            colors.setColor(location.getDocument(), color);
        }
       
        Color black = new Color(gc.getDevice(), 0, 0, 0);
        gc.setBackground(black);
        gc.fillRectangle(gc.getClipping());
        black.dispose();       
        Image image = new FastBackgroundRenderer(DEM, shading, mapInstance, colors, device).render();       
        gc.drawImage(image, 0, 0);
       
       
        gc.setForeground(new Color(gc.getDevice(), 255, 0, 0));
        for(int x = 0; x < mapInstance.width; x++) {
            for (int y = 0; y < mapInstance.height; y++) {
                Location kdTreeNearest = mapInstance.kdTreeNearest(x, y);
                Location naiveNearest = mapInstance.naiveNearest(x, y);
                if (naiveNearest.equals(kdTreeNearest)) continue;
               
                gc.drawPoint(x, y);
//                assertEquals(naiveNearest, kdTreeNearest);
            }
        }       
View Full Code Here

    @Override
    public void mouseDoubleClick(MouseEvent e) {
        MapInstance map = CodemapVisualization.mapValues(e).mapInstance.getValue();
        if (map == null) return;
        Location neighbor = map.nearestNeighbor(e.x, e.y);
        if (neighbor == null) return;
       
        IResource resource = Resources.asResource(neighbor.getDocument());
        if (!(resource instanceof IFile))
            return;
        EclipseUtil.openInEditor((IFile) resource);       
    }
View Full Code Here

    private void handleSingleClick(MouseEvent e) {
        // only update selection for clicks with primary mouse button
        if (e.button != 1) return;
       
        Value<MapInstance> mapInstance = mapValues(e).mapInstance;
        Location neighbor = mapInstance.getValueOrFail().nearestNeighbor(e.x, e.y);
        if (neighbor == null) return;
        if ((e.stateMask & SWT.SHIFT) != 0 || (e.stateMask & SWT.CTRL) != 0) {
            handleMultipleSelect(neighbor, getSelection(mapValues(e)));
        }
        else {
View Full Code Here

    }

    private void updateTooltip(MouseEvent e) {
        MapInstance map = mapValues.mapInstance.getValue();
        if (map == null) return;
        Location nearestNeighbor = map.nearestNeighbor(e.x, e.y);
       
        boolean noName = map.isEmpty() || !map.containsPoint(e.x, e.y) || nearestNeighbor == null;
        String name = noName ? null : nearestNeighbor.getName();
        textUpdater.updateNearestNeighbor(name);
    }
View Full Code Here

                    alphaBytes[i] = (byte) 255;
                    continue;
                }
                // get color from location a.k.a. hill colors
                nnStopWatch.start();
                Location nearestNeighbor = map.nearestNeighbor(x, y);
                MColor mcolor;
                if (nearestNeighbor == null) {
                    mcolor = colorScheme().getHillColor();
                } else {
                    mcolor = colors.forLocation(nearestNeighbor.getPoint());                   
                }
                nnStopWatch.stop();
                // make rgb
                int baseIndex = i*3;
                imageBytes[baseIndex++] = (byte) mcolor.getRed(); // R
View Full Code Here

TOP

Related Classes of org.codemap.Location

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.