var p = new Position({ capital: 10000, tolerableRiskInPercentOfCapitalPerTrade: 2, direction: Direction.LONG, pricePerUnit: 25, stopLossPricePerUnit: 24 });
String sql = "SELECT * FROM position WHERE id = ?"; Position position = (Position) jdbcTemplate.queryForObject( sql, new Object[] { id }, (ResultSet rs, int rowNum) -> { Position p = new Position(); p.setId(rs.getString("id")); p.setPositionName(rs.getString("position_name")); p.setDescription(rs.getString("description")); r eturn p; });
while (!cJoin.isAfterLast()) { Position p = new Position(); p.mLat = cJoin.getString(1); p.mLon = cJoin.getString(0); latLon[index++] = p; }
public Integer getValeur(int x, int y) { Position p=new Position(x,y); Integer m=valeurs.get(p); return m; }
public int getValeur(int x, int y) { Position p=new Position(x,y); Integer m=valeurs.get(p); if (m == null) { throw new IllegalArgumentException ("Invalid position " + x + "," + y); } return m; }
public class SpawnPoint { private Position position; public SpawnPoint(Position position) { this.position = position; } public SpawnPoint(int x, int y) { this(new Position(x, y)); } public Position getPosition() { return new Position(this.position); } }
public void mouseClicked(MouseEvent e){ int x = e.getX(); int y = e.getY(); j=x/50; h=y/50; board[j][h] = true; if(positions[j][h]==null){ positions[j][h]=new Position(x,y); } positions[j][h].setX(x); positions[j][h].setY(y); repaint(); }
public void writePositions() throws IOException, ClassNotFoundException { File file = new File("positions.ser"); FileOutputStream outFile = new FileOutputStream(file); ObjectOutputStream outStream = new ObjectOutputStream(outFile); public Position[] toTown = new Position[] { new Position(3094, 3491, 0), new Position(3088, 3487, 0), new Position(3080, 3475, 0)}; outStream.writeObject(toTown); outStream.close(); outFile.close(); }
Unit u = new Unit(new Position(1, 0)); System.out.println(u.myPos); // (1, 0) assuming toString() was overriden System.out.println(u.getPosition()); // null UnitType ut = u; System.out.println(ut.myPos); // null
string json = GetRequest.GetInstance(String.Format( "http://maps.google.com/maps/geo?q={0}&output=json", address)).DoRequest(String.Empty); JavaScriptSerializer serializer = new JavaScriptSerializer(); dynamic o = serializer.DeserializeObject(json); object[] coordinates = o["Placemark"][0]["Point"]["coordinates"]; return new Position() { Latitude = Convert.ToDouble(coordinates[0]), Longitude = Convert.ToDouble(coordinates[1]) };
public Position extractData(ResultSet rs) throws SQLException, DataAccessException { Position p = new Position(); if(rs.next()) { p.setId(rs.getString("id")); p.setPositionName(rs.getString("position_name")); p.setDescription(rs.getString("description")); } return p; }
protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
return getJdbcTemplate.query(sql, new RowMapper<Position>() { public Position mapRow(ResultSet rs, int row) throws SQLException, DataAccessException { Position p = new Position(); p.setId(rs.getString("id")); p.setPositionName(rs.getString("position_name")); p.setDescription(rs.getString("description")); return p; }, id); }
protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
protected void throwNoMoreContent() throws ParsingException { String msg = CommonI18n.noMoreContent.text(); Position pos = tokens.isEmpty() ? new Position(-1, 1, 0) : tokens.get(tokens.size() - 1).position(); throw new ParsingException(pos, msg); }
private static final double WGS84_RADIUS = 6370997.0; private static double EarthCircumFence = 2* WGS84_RADIUS * Math.PI; private static Position getPosition(Position sourcePosition, double mEastWest, double mNorthSouth){ double degreesPerMeterForLat = EarthCircumFence/360.0; double shrinkFactor = Math.cos((sourcePosition.getLat()*Math.PI/180)); double degreesPerMeterForLon = degreesPerMeterForLat * shrinkFactor; double newLat = sourcePosition.getLat() + mNorthSouth * (1/degreesPerMeterForLat); double newLng = sourcePosition.getLng() + mEastWest * (1/degreesPerMeterForLon); return new Position(newLat, newLng); }
Position wrapCircle(Circle circle, int width, int height) { final int radius = circle.getRadius(); final Position pos = circle.getPosition(); final int oldX = pos.getX(); final int x = (oldX > width + radius) ? -radius : ( (oldX < -radius) ? (width + radius) : oldX); final int y = // similar return new Position(x, y); } circle.setPosition(wrapCircle(circle, width, height));
private int combinedIndex( int firstIndex, int secondIndex ) { Position first = new Position(firstIndex, 1, 0); Position second = new Position(secondIndex, 1, 0); int firstPlusSecond = first.add(second).getIndexInContent(); int secondPlusFirst = second.add(first).getIndexInContent(); assertThat(firstPlusSecond, is(secondPlusFirst)); return firstPlusSecond; }
@Test public void shouldConvertPositionWhenUnableToParseFullTextSearchExpression() { try { parser.parseFullTextSearchExpression("", new Position(500, 100, 13)); fail("Should have thrown an exception"); } catch (ParsingException e) { assertThat(e.getPosition().getLine(), is(100)); assertThat(e.getPosition().getColumn(), is(13)); assertThat(e.getPosition().getIndexInContent(), is(500)); } }
@Test public void shouldConvertPositionWhenUnableToParseFullTextSearchExpression() { try { parser.parseFullTextSearchExpression("", new Position(500, 100, 13)); fail("Should have thrown an exception"); } catch (ParsingException e) { assertThat(e.getPosition().getLine(), is(100)); assertThat(e.getPosition().getColumn(), is(13)); assertThat(e.getPosition().getIndexInContent(), is(500)); } }