public int countImagesInSector(Sector sector, int levelNumber) { if (sector == null) { String msg = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } Level targetLevel = this.levels.getLastLevel(); if (levelNumber >= 0) { for (int i = levelNumber; i < this.getLevels().getLastLevel().getLevelNumber(); i++) { if (this.levels.isLevelEmpty(i)) continue; targetLevel = this.levels.getLevel(i); break; } } // Collect all the tiles intersecting the input sector. LatLon delta = targetLevel.getTileDelta(); Angle latOrigin = this.levels.getTileOrigin().getLatitude(); Angle lonOrigin = this.levels.getTileOrigin().getLongitude(); final int nwRow = Tile.computeRow(delta.getLatitude(), sector.getMaxLatitude(), latOrigin); final int nwCol = Tile.computeColumn(delta.getLongitude(), sector.getMinLongitude(), lonOrigin); final int seRow = Tile.computeRow(delta.getLatitude(), sector.getMinLatitude(), latOrigin); final int seCol = Tile.computeColumn(delta.getLongitude(), sector.getMaxLongitude(), lonOrigin); int numRows = nwRow - seRow + 1; int numCols = seCol - nwCol + 1; return numRows * numCols; }
protected Header readHeaderFromBuffer(ByteBuffer buffer) throws WWRuntimeException { // Read file code - first byte int fileCode = buffer.get(); if (fileCode > 5) { String message = Logging.getMessage("SHP.NotADBaseFile", file.getPath()); Logging.logger().log(java.util.logging.Level.SEVERE, message); throw new WWRuntimeException(message); } // Last update date int yy = 0xFF & buffer.get(); // unsigned int mm = buffer.get(); int dd = buffer.get(); // Number of records int numRecords = buffer.getInt(); // Header struct length int headerLength = buffer.getShort(); // Record length int recordLength = buffer.getShort(); // Assemble header Header header = new Header(); header.fileCode = fileCode; Calendar cal = Calendar.getInstance(); cal.set(1900 + yy, mm - 1, dd); header.lastModificationDate = cal.getTime(); header.numberOfRecords = numRecords; header.headerLength = headerLength; header.recordLength = recordLength; return header; }
public DBaseFile(InputStream is) { if (is == null) { String message = Logging.getMessage("nullValue.InputStreamIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.file = null; try { this.header = this.readHeaderFromStream(is); this.fields = this.readFieldsFromBuffer(this.header.fieldsHeaderBuffer); this.records = this.readRecordsFromStream(is); } catch (Exception e) { String message = Logging.getMessage("generic.ExceptionAttemptingToReadFrom", is.toString()); Logging.logger().log(java.util.logging.Level.SEVERE, message, e); throw new WWRuntimeException(message, e); } }
protected boolean loadTile(Tile tile, java.net.URL url) { if (WWIO.isFileOutOfDate(url, this.placeNameServiceSet.getExpiryTime())) { // The file has expired. Delete it then request download of newer. this.getDataFileStore().removeFile(url); String message = Logging.getMessage("generic.DataFileExpired", url); Logging.logger().fine(message); return false; } PlaceNameChunk tileData; synchronized (this.fileLock) { tileData = readTileData(tile, url); } if (tileData == null) { // Assume that something's wrong with the file and delete it. this.getDataFileStore().removeFile(url); tile.getPlaceNameService() .markResourceAbsent(tile.getPlaceNameService().getTileNumber(tile.row, tile.column)); String message = Logging.getMessage("generic.DeletedCorruptDataFile", url); Logging.logger().fine(message); return false; } tile.setDataChunk(tileData); WorldWind.getMemoryCache(Tile.class.getName()).add(tile.getFileCachePath(), tile); return true; }
public void write(DataRaster raster) throws IOException, IllegalArgumentException { if (null == raster) { String msg = Logging.getMessage("nullValue.RasterIsNull"); Logging.logger().finest(msg); throw new IllegalArgumentException(msg); } if (!(raster.getWidth() > 0)) { String msg = Logging.getMessage("generic.InvalidWidth", raster.getWidth()); Logging.logger().finest(msg); throw new IllegalArgumentException(msg); } if (!(raster.getHeight() > 0)) { String msg = Logging.getMessage("generic.InvalidHeight", raster.getHeight()); Logging.logger().finest(msg); throw new IllegalArgumentException(msg); } if (raster instanceof BufferedImageRaster) { this.write(((BufferedImageRaster) raster).getBufferedImage(), raster); } else if (raster instanceof BufferWrapperRaster) { this.writeRaster((BufferWrapperRaster) raster); } }
/** * Create an instance. * * @param tc the current {@link KMLTraversalContext}. * @param placemark the <i>Placemark</i> element containing the <i>Point</i>. * @param geom the {@link gov.nasa.worldwind.ogc.kml.KMLPoint} geometry. * @throws NullPointerException if the geometry is null. * @throws IllegalArgumentException if the parent placemark or the traversal context is null. */ public KMLModelPlacemarkImpl( KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom) { if (tc == null) { String msg = Logging.getMessage("nullValue.TraversalContextIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } if (placemark == null) { String msg = Logging.getMessage("nullValue.ParentIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } if (geom == null) { String msg = Logging.getMessage("nullValue.GeometryIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } this.model = (KMLModel) geom; this.parent = placemark; this.resourceMap = this.createResourceMap(this.model); }
public void makeOrderedRenderable(DrawContext dc, AirspaceRenderer renderer) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (renderer == null) { String message = Logging.getMessage("nullValue.RendererIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } for (Layer layer : this.layers) { if (!layer.isVisible()) continue; if (!layer.isAirspaceVisible(dc)) continue; // The layer is responsible for applying its own attributes, so we override its attributes // with our own just // before rendering. layer.setAttributes(this.getAttributes()); // Create an ordered renderable that draws each layer, but specifies this Cake as the picked // object. OrderedRenderable or = renderer.createOrderedRenderable(dc, layer, layer.computeEyeDistance(dc), this); dc.addOrderedRenderable(or); } }
public int computeLevelForResolution(Sector sector, Globe globe, double resolution) { if (sector == null) { String message = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (globe == null) { String message = Logging.getMessage("nullValue.GlobeIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } double texelSize = 0; Level targetLevel = this.levels.getLastLevel(); for (int i = 0; i < this.getLevels().getLastLevel().getLevelNumber(); i++) { if (this.levels.isLevelEmpty(i)) continue; texelSize = this.levels.getLevel(i).getTexelSize(); if (texelSize > resolution) continue; targetLevel = this.levels.getLevel(i); break; } Logging.logger() .info( Logging.getMessage( "layers.TiledImageLayer.LevelSelection", targetLevel.getLevelNumber(), texelSize)); return targetLevel.getLevelNumber(); }
@Override protected Layer doCreateFromCapabilities(OGCCapabilities caps, AVList params) { String serviceName = caps.getServiceInformation().getServiceName(); if (serviceName == null || !(serviceName.equalsIgnoreCase(OGCConstants.WMS_SERVICE_NAME) || serviceName.equalsIgnoreCase("WMS"))) { String message = Logging.getMessage("WMS.NotWMSService", serviceName != null ? serviceName : "null"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (params == null) params = new AVListImpl(); if (params.getStringValue(AVKey.LAYER_NAMES) == null) { // Use the first named layer since no other guidance given List<WMSLayerCapabilities> namedLayers = ((WMSCapabilities) caps).getNamedLayers(); if (namedLayers == null || namedLayers.size() == 0 || namedLayers.get(0) == null) { String message = Logging.getMessage("WMS.NoLayersFound"); Logging.logger().severe(message); throw new IllegalStateException(message); } params.setValue(AVKey.LAYER_NAMES, namedLayers.get(0).getName()); } return new WMSTiledImageLayer((WMSCapabilities) caps, params); }
/** * Create a new WebView. * * @param frameSize The size of the WebView rectangle. * @throws UnsupportedOperationException if this class is instantiated on a non-Windows operating * system. * @throws WWRuntimeException if creating the native web browser window fails for any reason. For * example, because the process has run out of User Object handles (see documentation <a * href="#limits">above</a>). */ public WindowsWebView(Dimension frameSize) { if (frameSize == null) { String message = Logging.getMessage("nullValue.SizeIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (!Configuration.isWindowsOS()) { String message = Logging.getMessage( "NativeLib.UnsupportedOperatingSystem", "Windows WebView", System.getProperty("os.name")); Logging.logger().severe(message); throw new UnsupportedOperationException(message); } this.frameSize = frameSize; try { // Increment the instance counter instances.incrementAndGet(); // Make sure that the message loop thread is running this.ensureMessageLoopRunning(); // Create the web view this.webViewWindowPtr = WindowsWebViewJNI.newWebViewWindow(webViewMessageLoop); if (this.webViewWindowPtr == 0) { String message = Logging.getMessage("WebView.NativeExceptionInitializingWebView"); Logging.logger().severe(message); throw new WWRuntimeException(message); } WindowsWebViewJNI.setFrameSize( this.webViewWindowPtr, this.frameSize.width, this.frameSize.height); this.observerPtr = WindowsWebViewJNI.newNotificationAdapter(this); WindowsWebViewJNI.addWindowUpdateObserver(this.webViewWindowPtr, observerPtr); } catch (RuntimeException e) { // If the WebView was not created successfully do not increment the instance counter. instances.decrementAndGet(); this.handleWebViewCreationError(); throw e; } catch (Error e) { // If the WebView was not created successfully do not increment the instance counter. instances.decrementAndGet(); this.handleWebViewCreationError(); throw e; } }
/** * Verifies that the record's shape type matches the expected one, typically that of the * shapefile. All non-null records in a Shapefile must be of the same type. Throws an exception if * the types do not match and the shape type is not <code>{@link Shapefile#SHAPE_NULL}</code>. * Records of type <code>SHAPE_NULL</code> are always valid, and may appear in any Shapefile. * * <p>For details, see the ESRI Shapefile specification at <a * href="http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf"/>, pages 4 and 5. * * @param shapefile the shapefile. * @param shapeType the record's shape type. * @throws WWRuntimeException if the shape types do not match. * @throws IllegalArgumentException if the specified shape type is null. */ protected void validateShapeType(Shapefile shapefile, String shapeType) { if (shapeType == null) { String message = Logging.getMessage("nullValue.ShapeType"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (!shapeType.equals(shapefile.getShapeType()) && !shapeType.equals(Shapefile.SHAPE_NULL)) { String message = Logging.getMessage("SHP.UnsupportedShapeType", shapeType); Logging.logger().severe(message); throw new WWRuntimeException(message); } }
public synchronized void removePropertyChangeListener( String propertyName, java.beans.PropertyChangeListener listener) { if (propertyName == null) { String msg = Logging.getMessage("nullValue.PropertyNameIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } if (listener == null) { String msg = Logging.getMessage("nullValue.ListenerIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } this.getChangeSupport().removePropertyChangeListener(propertyName, listener); }
public synchronized String getStringValue(String key) { if (key == null) { String msg = Logging.getMessage("nullValue.AttributeKeyIsNull"); Logging.logger().severe(msg); throw new IllegalStateException(msg); } try { return (String) this.getValue(key); } catch (ClassCastException e) { String msg = Logging.getMessage("AVAAccessibleImpl.AttributeValueForKeyIsNotAString", key); Logging.logger().severe(msg); throw new WWRuntimeException(msg, e); } }
public void run() { if (Thread.currentThread().isInterrupted()) return; // the task was cancelled because it's a duplicate or for some other reason try { this.placemark.retrieveModel(this.address); } catch (IOException e) { String message = Logging.getMessage("generic.ExceptionWhileReading", e.getMessage()); Logging.logger().warning(message); } catch (XMLStreamException e) { String message = Logging.getMessage("generic.ExceptionAttemptingToParseXml", e.getMessage()); Logging.logger().warning(message); } }
/** * Create a collection of layer lists and their included layers described by an array of XML * layer-list description elements. * * <p>Any exceptions occurring during creation of the layer lists or their included layers are * logged and not re-thrown. The layers associated with the exceptions are not included in the * returned layer list. * * @param elements the XML elements describing the layer lists to create. * @param params any parameters to apply when creating the included layers. * @return an array containing the specified layer lists. */ protected LayerList[] createLayerLists(Element[] elements, AVList params) { ArrayList<LayerList> layerLists = new ArrayList<LayerList>(); for (Element element : elements) { try { String href = WWXML.getText(element, "@href"); if (href != null && href.length() > 0) { Object o = this.createFromConfigSource(href, params); if (o == null) continue; if (o instanceof Layer) { LayerList ll = new LayerList(); ll.add((Layer) o); o = ll; } if (o instanceof LayerList) { LayerList list = (LayerList) o; if (list != null && list.size() > 0) layerLists.add(list); } else if (o instanceof LayerList[]) { LayerList[] lists = (LayerList[]) o; if (lists != null && lists.length > 0) layerLists.addAll(Arrays.asList(lists)); } else { String msg = Logging.getMessage("LayerFactory.UnexpectedTypeForLayer", o.getClass().getName()); Logging.logger().log(java.util.logging.Level.WARNING, msg); } continue; } String title = WWXML.getText(element, "@title"); Element[] children = WWXML.getElements(element, "./Layer", null); if (children != null && children.length > 0) { LayerList list = this.createLayerList(children, params); if (list != null && list.size() > 0) { layerLists.add(list); if (title != null && title.length() > 0) list.setValue(AVKey.DISPLAY_NAME, title); } } } catch (Exception e) { Logging.logger().log(java.util.logging.Level.WARNING, e.getMessage(), e); // keep going to create other layers } } return layerLists.toArray(new LayerList[layerLists.size()]); }
public boolean isAirspaceVisible(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } // If the parent Cake is not visible, then return false immediately without testing the child // layers. if (!super.isAirspaceVisible(dc)) return false; boolean visible = false; // The parent Cake is visible. Since the parent Cake's extent potentially contains volumes where // no child // geometry exists, test that at least one of the child layers are visible. for (Layer l : this.layers) { if (l.isAirspaceVisible(dc)) { visible = true; break; } } return visible; }
public void doActionOnButton3() { // Sector sector = Sector.fromDegrees( 44d, 46d, -123.3d, -123.2d ); ArrayList<LatLon> latlons = new ArrayList<LatLon>(); latlons.add(LatLon.fromDegrees(45.50d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.52d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.54d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.56d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.58d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.60d, -123.3d)); ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel(); StringBuffer sb = new StringBuffer(); for (LatLon ll : latlons) { double e = model.getElevation(ll.getLatitude(), ll.getLongitude()); sb.append("\n").append(e); } Logging.logger().info(sb.toString()); }
/** * Construct a request task for a specified network link resource. * * @param placemark the placemark for which to construct the request task. * @param address the address of the resource to request. */ protected RequestTask(KMLModelPlacemarkImpl placemark, String address) { if (placemark == null) { String message = Logging.getMessage("nullValue.ObjectIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (address == null) { String message = Logging.getMessage("nullValue.PathIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.placemark = placemark; this.address = address; }
public boolean isLayerInView(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (dc.getView() == null) { String message = Logging.getMessage("layers.AbstractLayer.NoViewSpecifiedInDrawingContext"); Logging.logger().severe(message); throw new IllegalStateException(message); } return !(dc.getVisibleSector() != null && !this.levels.getSector().intersects(dc.getVisibleSector())); }
/** {@inheritDoc} */ public void dispose() { if (this.disposed) // Do not dispose the WebView multiple times return; try { // Remove the notification adapter if (webViewWindowPtr != 0 && observerPtr != 0) WindowsWebViewJNI.removeWindowUpdateObserver(webViewWindowPtr, observerPtr); // Free the native WebView object associated with this Java WebView object. if (webViewWindowPtr != 0) { WindowsWebViewJNI.releaseWebView(webViewWindowPtr); // Decrement the instance counter. Only do this if the webViewWindow pointer was non-zero, // indicating // that native resources were actually allocated. instances.decrementAndGet(); } if (observerPtr != 0) WindowsWebViewJNI.releaseComObject(observerPtr); this.webViewWindowPtr = 0; this.observerPtr = 0; // Terminate the message loop thread if this is the last active instance. this.stopMessageLoopIfNoInstances(); this.disposed = true; } catch (Exception e) { Logging.logger() .log( Level.SEVERE, Logging.getMessage("generic.ExceptionAttemptingToDisposeRenderable"), e); } }
/** * @param placeNameServiceSet the set of PlaceNameService objects that PlaceNameLayer will render. * @throws IllegalArgumentException if {@link * gov.nasa.worldwind.layers.placename.PlaceNameServiceSet} is null */ public PlaceNameLayer(PlaceNameServiceSet placeNameServiceSet) { if (placeNameServiceSet == null) { String message = Logging.getMessage("nullValue.PlaceNameServiceSetIsNull"); Logging.logger().fine(message); throw new IllegalArgumentException(message); } // this.placeNameServiceSet = placeNameServiceSet.deepCopy(); for (int i = 0; i < this.placeNameServiceSet.getServiceCount(); i++) { // todo do this for long as well and pick min int calc1 = (int) (PlaceNameService.TILING_SECTOR.getDeltaLatDegrees() / this.placeNameServiceSet .getService(i) .getTileDelta() .getLatitude() .getDegrees()); int numLevels = (int) Math.log(calc1); navTiles.add( new NavigationTile( this.placeNameServiceSet.getService(i), PlaceNameService.TILING_SECTOR, numLevels, "top")); } if (!WorldWind.getMemoryCacheSet().containsCache(Tile.class.getName())) { long size = Configuration.getLongValue(AVKey.PLACENAME_LAYER_CACHE_SIZE, 2000000L); MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size); cache.setName("Placename Tiles"); WorldWind.getMemoryCacheSet().addCache(Tile.class.getName(), cache); } }
public void setAzimuths(Angle leftAzimuth, Angle rightAzimuth) { if (leftAzimuth == null) { String message = "nullValue.LeftAzimuthIsNull"; Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (rightAzimuth == null) { String message = "nullValue.RightAzimuthIsNull"; Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.leftAzimuth = leftAzimuth; this.rightAzimuth = rightAzimuth; this.setExtentOutOfDate(); }
/** * Causes resources used by the World Window to be freed. The World Window cannot be used once * this method is called. An OpenGL context for the window must be current. */ public void shutdown() { WorldWind.getDataFileStore().removePropertyChangeListener(this); if (this.inputHandler != null) { this.inputHandler.dispose(); this.inputHandler = new NoOpInputHandler(); } // Clear the texture cache if (this.getGpuResourceCache() != null) this.getGpuResourceCache().clear(); // Dispose all the layers // TODO: Need per-window dispose for layers if (this.getModel() != null && this.getModel().getLayers() != null) { for (Layer layer : this.getModel().getLayers()) { try { layer.dispose(); } catch (Exception e) { Logging.logger() .log( java.util.logging.Level.SEVERE, Logging.getMessage("WorldWindowGLCanvas.ExceptionWhileShuttingDownWorldWindow"), e); } } } SceneController sc = this.getSceneController(); if (sc != null) sc.dispose(); }
/** * This method is called by the constructor if an exception is thrown creating the WebView. It * gives the WebView a change to cleanup static state that may have been set during the failed * WebView construction. */ protected void handleWebViewCreationError() { try { this.stopMessageLoopIfNoInstances(); } catch (Throwable t) { String message = Logging.getMessage("WebView.ExceptionStoppingWebViewThread", t); Logging.logger().severe(message); } }
static int computeColumn(Angle delta, Angle longitude) { if (delta == null || longitude == null) { String msg = Logging.getMessage("nullValue.AngleIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } return (int) ((longitude.getDegrees() + 180d) / delta.getDegrees()); }
static Angle computeRowLatitude(int row, Angle delta) { if (delta == null) { String msg = Logging.getMessage("nullValue.AngleIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } return Angle.fromDegrees(-90d + delta.getDegrees() * row); }
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (propertyName == null) { String msg = Logging.getMessage("nullValue.PropertyNameIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } this.getChangeSupport().firePropertyChange(propertyName, oldValue, newValue); }
public void firePropertyChange(java.beans.PropertyChangeEvent propertyChangeEvent) { if (propertyChangeEvent == null) { String msg = Logging.getMessage("nullValue.PropertyChangeEventIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } this.getChangeSupport().firePropertyChange(propertyChangeEvent); }
static Angle computeColumnLongitude(int column, Angle delta) { if (delta == null) { String msg = Logging.getMessage("nullValue.AngleIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } return Angle.fromDegrees(-180 + delta.getDegrees() * column); }
public PartialCappedCylinder( LatLon location, double radius, Angle leftAzimuth, Angle rightAzimuth) { super(location, radius); if (leftAzimuth == null) { String message = "nullValue.LeftAzimuthIsNull"; Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (rightAzimuth == null) { String message = "nullValue.RightAzimuthIsNull"; Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.leftAzimuth = leftAzimuth; this.rightAzimuth = rightAzimuth; }