do { myCoord = new Coord(); //********** myCoord.userId = cur.getInt(0); myCoord.timestamp = cur.getLong(1); myCoord.x = cur.getDouble(2); myCoord.y = cur.getDouble(3); myCoord.coordType = cur.getInt(4); myCoord.id = cur.getInt(5); myCoord.coordTypeDesc = cur.getString(6); markerArray.add(myCoord); Log.d("getCoordMarkers()", "X: " + myCoord.x + " Y: " + myCoord.y); myCoord = null; //for the garbage collector ******* } while( cur.moveToNext());
public static Coord get(final int x, final int y) { if(x >= -3 && y >= -3 && x < POOL.length - 3 && y < POOL[x + 3].length - 3) return POOL[x + 3][y + 3]; else return new Coord(x, y); }
Coord getCoordWithList(ArrayList<Coord> data, int x, int y) { Coord coord = new Coord(x, y); int index = data.indexOf(coord); if (index > -1) { return data.get(index); } return null; }
public static List<Coord> getCoordinates(int x, int y) { List<Coord> al = new ArrayList<>(); for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { al.add(new Coord(i, j)); } } return al; }
public class Player extends Entity { private Coord coordinates; public Player(int x, int y) { coordinates = new Coord(x,y); System.out.println(“Player is at coordinate “ + obj.getX() + “,” + obj.getY()); } public Coord getCoordinates() { return coordinates; } }
int x = ...; //x is some int int y = ...; //y is some int Coord coordOriginal = new Coord(x, y); Coord coordCopy = new Coord(coordOriginal);
int i=0; while(temp.hasNextLine()) { String line = temp.nextLine(); for (int j = 0; j < cols; j++) { if(x == line.charAt(j)) { treasureLocations[location] = new Coord(i, j); location++; } } } ++i; }
String jsonDataString = this.getSharedPreferencesStringValue(ctx, "positions", "last_positions"); Gson gson = new Gson(); MyObject obj = gson.fromJson(jsonDataString, MyObject.class); // Noew obj contains your JSON data, so you can manipulate it at your will. Coord newCoord = new Coord(); newCoord.lat = 34.66; newCoord.lon = -4.567; obj.results.add(newCoord); String newJsonString = gson.toJson(obj);
String input = Files.toString(file, Charsets.US_ASCII); Iterable<String> fields = Splitter.on(" ") .omitEmptyStrings() .split(input); List<Coord> coords = Lists.newArrayList(); for (List<String> group: Iterables.partition(fields, 3)) { String t = group.get(0); double x = Double.parseDouble(group.get(1)); double y = Double.parseDouble(group.get(2)); coords.add(new Coord(t, x, y)); }
int x = ...; //x is some int int y = ...; //y is some int Coord coordOriginal = new Coord(x, y); //coordOriginal points to a new Coord object. Let's call it "A". Coord coordCopy = coordOriginal.copy(); //coordCopy points to to a new Coord object. Let's call it "B". //coordOriginal still points to Coord object "A".
public static String printGrid(HashMap<Coord, Integer> map, int width, int height) { StringBuilder grid = new StringBuilder(height * (width + 1)); // Pre-sizing is optional, but // may improve performance a bit for (int row = 0; row < height; row++) { for (int column = 0; column < width; column++) { Integer value = map.get(new Coord(column, row)); if (value != null) { grid.append(value); } else { grid.append('#'); } } grid.append('\n'); // next row } return grid.toString(); }
Coord getCoord(HashSet<Coord> data, int x, int y) { Coord coord = new Coord(x, y); if (data.contains(coord)) { for (Coord c : data) { if (c.equals(coord)){ return c; } } } return null; }
Scanner sc = new Scanner(coords); sc.useDelimiter("\\D*"); // skip everything that is not a digit List<Coord> result = new ArrayList<Coord>(); while (sc.hasNextInt()) { result.add(new Coord(sc.nextInt(), sc.nextInt())); } return result;
public class Player extends Entity { Coord obj; public Player(int x, int y) { obj = new Coord(x,y); System.out.println(“Player is at coordinate “ + obj.getX() + “,” + obj.getY()); } }
@Override protected void beforeMapaGPS(Form f) { MapComponent mapComponent= new MapComponent(); double latitude=-41.169782; double longitude =-71.444885; Coord lastLocation = new Coord(latitude, longitude); mapComponent.zoomTo(lastLocation, 15); f.setLayout(new BorderLayout()); f.addComponent(BorderLayout.CENTER, mapComponent); }
public void paint(Graphics g) { int incX = 5; // initial x increment for circle locations int incY = 5; // initial y increment for circle locations Coord temp = new Coord(0,0); Queue<Coord> q = new LinkedList<Coord>(); Circle c = new Circle(g,circleSize,incX,incY,TIME_DELAY); try { for(int i = 1; i <= TOTAL_NUM_CIRCLES; i++) { if(q.size() >= 50) { temp = q.remove(); c.eraseCircle(g,temp.getX(),temp.getY()); } temp = new Coord(getX(),getY()); //q.add(temp); q.add(c.drawCircle(g)); c.hitEdge(); } } catch(InterruptedException e){} }
@Override protected void beforeGUI1(Form f) { MapComponent mapComponent= new MapComponent(); double latitude=-41.169782; double longitude =-71.444885; Coord lastLocation = new Coord(latitude, longitude); mapComponent.zoomTo(lastLocation, 15); f.setLayout(new BorderLayout()); f.addComponent(BorderLayout.CENTER, mapComponent); }
private static Coord fillMatrix() { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); matrix = new Integer[size][size]; Coord coord = new Coord(0, 0); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (sc.hasNextInt()) { int util = sc.nextInt(); matrix[i][j] = util; } else { sc.next(); coord.row = i; coord.col = j; matrix[i][j] = null; } } } sc.close(); return coord; }
for (int i = 0; i < N_ROWS; i++) { for (int j = 0; j < N_COLS; j++) { Button button = new Button(); button.setUserData(new Coord(i,j)); button.setOnAction(event -> takeActionForCoord((Coord) button.getUserData())); pane.getChildren().add(button); } }