@Override public ReadOnlyIntegerProperty preloadMapTiles(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) { ReadOnlyIntegerWrapper remainingCount = new ReadOnlyIntegerWrapper(); int minX = getTileX(minLongitude, ZOOM); int maxX = getTileX(maxLongitude, ZOOM); int minY = getTileY(minLatitude, ZOOM); int maxY = getTileY(maxLatitude, ZOOM); int totalCount = (maxX-minX+1)*(maxY-minY+1); if (totalCount > MAX_TILES) { throw new IllegalArgumentException("The number of tiles required ("+totalCount+") is greater than the maximum allowed ("+MAX_TILES+")"); } int remaining = 0; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { File f = getCacheFile(ZOOM, x, y); if (!f.exists()) { remaining++; fetchAndStoreTile(remainingCount, ZOOM, x, y); } } } remainingCount.set(remaining); return remainingCount; }
public HourMinSecTextField(String time) { super(time); this.time = new SimpleLongProperty(); timePattern = Pattern.compile("\\d\\d:\\d\\d:\\d\\d"); if (!validate(time)) { throw new IllegalArgumentException("Invalid time: " + time); } hours = new ReadOnlyIntegerWrapper(this, "hours"); minutes = new ReadOnlyIntegerWrapper(this, "minutes"); hours.bind(new TimeUnitBinding(Unit.HOURS)); minutes.bind(new TimeUnitBinding(Unit.MINUTES)); seconds = new ReadOnlyIntegerWrapper(this, "seconds"); seconds.bind(new TimeUnitBinding(Unit.SECONDS)); this.time.bind(seconds.add(minutes.multiply(60).add(hours.multiply(60)))); }
public AbstractOpenGLRenderer(final StreamHandler readHandler) { this.pendingRunnables = new ConcurrentLinkedQueue<Runnable>(); this.fps = new ReadOnlyIntegerWrapper(this, "fps", 0); if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) throw new UnsupportedOperationException("Support for pbuffers is required."); try { pbuffer = new Pbuffer(1, 1, new PixelFormat(), null, null, new ContextAttribs().withDebug(false)); pbuffer.makeCurrent(); } catch (LWJGLException e) { throw new RuntimeException(e); } final ContextCapabilities caps = GLContext.getCapabilities(); if (caps.GL_ARB_debug_output) { glDebugMessageCallbackARB(new ARBDebugOutputCallback()); } else if (caps.GL_AMD_debug_output) { glDebugMessageCallbackAMD(new AMDDebugOutputCallback()); } this.renderStreamFactory = StreamUtil.getRenderStreamImplementation(); this.renderStream = renderStreamFactory.create(readHandler, samples, transfersToBuffer); }
/** * Instantiates a World object with the specified parameters. * * @param name * The name of the World * @param width * The width of the World * @param height * The height of the World * @param baseTileType * The initial tile type to set every tile to */ public World(String name, int width, int height, int baseTileType, long seed) { tiles = new Array2D<>(width, height); this.seed = seed; this.height = new ReadOnlyIntegerWrapper(height); this.width = new ReadOnlyIntegerWrapper(width); initialise(); for (int y = 0; y < getHeight(); y++) { for (int x = 0; x < getWidth(); x++) { tiles.set(x, y, new Tile(x, y, baseTileType)); } } buildings = new HashSet<>(); this.name = name; this.modifierManager = new ModifierManager(); this.seasonManager = new SeasonManager(); this.weatherManager = new WeatherManager(); this.fireManager = new FireManager(this); this.timeManager = new DayNight(); this.contractGenerator = new ContractGenerator(); this.activeContracts = new ContractHandler(); this.availableContracts = new ContractHandler(); this.storageManager = new StorageManager(); this.predatorManager = new PredatorManager(); this.buildingPlacer = new BuildingPlacer(); this.moneyHandler = new Money(); }
private void fetchAndStoreTile(ReadOnlyIntegerWrapper remaining, int zoom, int x, int y) { BackgroundTasks.runInBackground(() -> { try { String urlString = TILE_HOST+zoom+"/"+x+"/"+y+".png"; URL url = new URL(urlString); try (InputStream inputStream = url.openConnection().getInputStream()) { File candidate = getCacheFile(zoom, x, y); candidate.getParentFile().mkdirs(); try (FileOutputStream fos = new FileOutputStream(candidate)) { byte[] buff = new byte[4096]; int len = inputStream.read(buff); while (len > 0) { fos.write(buff, 0, len); len = inputStream.read(buff); } fos.close(); } } } catch (IOException ex) { LOG.log(Level.SEVERE, "Failed to fetch & store map tile "+x+","+y, ex); } finally { Platform.runLater(() -> { remaining.set(remaining.get()-1);//Identify it as loaded regardless }); } }); }
public HourMinTextField(String time) { super(time); this.time = new SimpleLongProperty(); timePattern = Pattern.compile("\\d\\d:\\d\\d"); if (!validate(time)) { throw new IllegalArgumentException("Invalid time: " + time); } hours = new ReadOnlyIntegerWrapper(this, "hours"); minutes = new ReadOnlyIntegerWrapper(this, "minutes"); hours.bind(new TimeUnitBinding(Unit.HOURS)); minutes.bind(new TimeUnitBinding(Unit.MINUTES)); this.time.bind(minutes.add(hours.multiply(60))); }
/** Replies the property that is the width of the box. * * @return the width property. */ @Pure public IntegerProperty widthProperty() { if (this.width == null) { this.width = new ReadOnlyIntegerWrapper(this, MathFXAttributeNames.WIDTH); this.width.bind(Bindings.subtract(maxXProperty(), minXProperty())); } return this.width; }
/** Replies the property that is the height of the box. * * @return the height property. */ @Pure public IntegerProperty heightProperty() { if (this.height == null) { this.height = new ReadOnlyIntegerWrapper(this, MathFXAttributeNames.HEIGHT); this.height.bind(Bindings.subtract(maxYProperty(), minYProperty())); } return this.height; }
/** Replies the property that is the depth of the box. * * @return the depth property. */ @Pure public IntegerProperty depthProperty() { if (this.depth == null) { this.depth = new ReadOnlyIntegerWrapper(this, MathFXAttributeNames.DEPTH); this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty())); } return this.depth; }
public Vulnerability(int vulnerability) { this.vulnerability = new ReadOnlyIntegerWrapper(vulnerability); }