public DynamicLayerConfig addLayerConfig(String name, int type, String query) { if (!query.startsWith("{")) { // Not a JSON query, must be CQL, so check the syntax try { ECQL.toFilter(query); } catch (CQLException e) { throw new SpatialDatabaseException( "DynamicLayer query is not JSON and not valid CQL: " + query, e); } } Layer layer = getLayerMap().get(name); if (layer != null) { if (layer instanceof DynamicLayerConfig) { DynamicLayerConfig config = (DynamicLayerConfig) layer; if (config.getGeometryType() != type || !config.getQuery().equals(query)) { System.err.println( "Existing LayerConfig with different geometry type or query: " + config); return null; } else { return config; } } else { System.err.println( "Existing Layer has same name as requested LayerConfig: " + layer.getName()); return null; } } else synchronized (this) { DynamicLayerConfig config = new DynamicLayerConfig(this, name, type, query); layers = null; // force recalculation of layers cache return config; } }
/** Creates a JDOM Element as defined in <a href="http://jpos.org/minigl.dtd">minigl.dtd</a> */ public Element toXML() { Element elem = new Element("journal"); elem.addContent(new Comment("id " + getId())); elem.addContent(new Element("name").setText(getName())); elem.addContent(new Element("start").setText(Util.dateToString(getStart()))); Date d = getEnd(); if (d != null) elem.addContent(new Element("end").setText(Util.dateToString(d))); if (isClosed()) elem.addContent(new Element("status").setText("closed")); elem.addContent(new Element("chart").setText(getChart().getCode())); Iterator iter = getLayers().iterator(); while (iter.hasNext()) { Layer l = (Layer) iter.next(); elem.addContent(l.toXML()); } iter = getPermissions().iterator(); while (iter.hasNext()) { GLPermission p = (GLPermission) iter.next(); Element e = new Element("grant").setText(p.getName()); e.setAttribute("user", p.getUser().getNick()); elem.addContent(e); } return elem; }
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); } }
/** * Create a {@link TiledImageLayer} layer described by an XML layer description. * * @param domElement the XML element describing the layer to create. The element must inculde a * service name identifying the type of service to use to retrieve layer data. Recognized * service types are "Offline", "WWTileService" and "OGC:WMS". * @param params any parameters to apply when creating the layer. * @return a new layer * @throws WWUnrecognizedException if the service type given in the describing element is * unrecognized. */ protected Layer createTiledImageLayer(Element domElement, AVList params) { Layer layer; String serviceName = WWXML.getText(domElement, "Service/@serviceName"); if ("Offline".equals(serviceName)) { layer = new BasicTiledImageLayer(domElement, params); } else if ("WWTileService".equals(serviceName)) { layer = new BasicTiledImageLayer(domElement, params); } else if (OGCConstants.WMS_SERVICE_NAME.equals(serviceName)) { layer = new WMSTiledImageLayer(domElement, params); } else if (AVKey.SERVICE_NAME_LOCAL_RASTER_SERVER.equals(serviceName)) { layer = new LocalRasterServerLayer(domElement, params); } else { String msg = Logging.getMessage("generic.UnrecognizedServiceName", serviceName); throw new WWUnrecognizedException(msg); } // // String name = layer.getStringValue(AVKey.DISPLAY_NAME); // System.out.println(name); String actuate = WWXML.getText(domElement, "@actuate"); layer.setEnabled(actuate != null && actuate.equals("onLoad")); return layer; }
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; }
/** * This method handles shuffling together two gcodes, it first executes preprocessing and then * hands the gcodes off to Layer_Helper */ public void combine() { MutableGCodeSource left, right; // load our layers into something we can use left = new MutableGCodeSource(leftFile); right = new MutableGCodeSource(rightFile); // remove some tags we don't want/get SkeinforgePostProcessor.stripNonLayerTagComments(left); SkeinforgePostProcessor.stripNonLayerTagComments(right); // load our layers into something we can *really* use LinkedList<Layer> leftLayers = parseLayers(left); LinkedList<Layer> rightLayers = parseLayers(right); // merge our layers into one list final LinkedList<Layer> layers = doMerge(leftLayers, rightLayers); // refresh and repopulate our result result = new MutableGCodeSource(); for (Layer l : layers) { result.add(l.getCommands()); } // add start gcode, updated based on settings SkeinforgePostProcessor.prependAndModifyStartCode(result, startGCode); // add end code Layer endLayer = new Layer(Double.MAX_VALUE, endGCode.asList()); result.add(endLayer.toString()); // interlace progress updates result.addProgressUpdates(); }
public Layer createLayer(Layer layer) { layer.id = getNextLayerId(); layer.rank = getNextLayerRank(); layers.put(layer.id, layer); return layer; }
/** @return a byte array with the vector tile */ public byte[] encode() { VectorTile.Tile tile = new VectorTile.Tile(); List<VectorTile.Tile.Layer> tileLayers = new ArrayList<VectorTile.Tile.Layer>(); for (Map.Entry<String, Layer> e : layers.entrySet()) { String layerName = e.getKey(); Layer layer = e.getValue(); VectorTile.Tile.Layer tileLayer = new VectorTile.Tile.Layer(); tileLayer.version = 1; tileLayer.name = layerName; tileLayer.keys = layer.keys(); List<VectorTile.Tile.Value> values = new ArrayList<VectorTile.Tile.Value>(); for (Object value : layer.values()) { VectorTile.Tile.Value tileValue = new VectorTile.Tile.Value(); if (value instanceof String) { tileValue.setStringValue((String) value); } else if (value instanceof Integer) { tileValue.setSintValue(((Integer) value).intValue()); } else if (value instanceof Long) { tileValue.setSintValue(((Long) value).longValue()); } else if (value instanceof Float) { tileValue.setFloatValue(((Float) value).floatValue()); } else if (value instanceof Double) { tileValue.setDoubleValue(((Double) value).doubleValue()); } else { tileValue.setStringValue(value.toString()); } values.add(tileValue); } tileLayer.values = values.toArray(new VectorTile.Tile.Value[values.size()]); tileLayer.setExtent(extent); List<VectorTile.Tile.Feature> features = new ArrayList<VectorTile.Tile.Feature>(); for (Feature feature : layer.features) { Geometry geometry = feature.geometry; VectorTile.Tile.Feature featureBuilder = new VectorTile.Tile.Feature(); featureBuilder.tags = toIntArray(feature.tags); featureBuilder.setType(toGeomType(geometry)); featureBuilder.geometry = toIntArray(commands(geometry)); features.add(featureBuilder); } tileLayer.features = features.toArray(new VectorTile.Tile.Feature[features.size()]); tileLayers.add(tileLayer); } tile.layers = tileLayers.toArray(new VectorTile.Tile.Layer[tileLayers.size()]); return MessageNano.toByteArray(tile); }
public Position getReferencePosition() { ArrayList<LatLon> locations = new ArrayList<LatLon>(this.layers.size()); for (Layer l : this.layers) { locations.add(l.getCenter()); } return this.computeReferencePosition(locations, this.getAltitudes()); }
public Layer getLayer(long id) { for (Layer layer : this.layers.values()) { if (layer.getId() == id) { return layer; } } return null; }
/** * Finds all entities of a type on the map. * * @param entityType a type of entity * @return the list of the entities of this kind on the map */ public List<MapEntity> getEntitiesOfType(EntityType entityType) { List<MapEntity> list = new LinkedList<MapEntity>(); for (Layer layer : Layer.values()) { list.addAll(allEntities[layer.getId()].getEntitiesOfType(entityType)); } return list; }
private final IAnimation draw() { final Layer layer = m_movie.getLayer(); if (null != layer) { layer.batch(); } return this; }
/** * Sets the style for a linear layer. * * @param vertexSize 0 if vertices are not to be shown */ public static void setLinearStyle(Layer lyr, Color lineColor, int lineWidth, int vertexSize) { lyr.getBasicStyle().setLineColor(lineColor); lyr.getBasicStyle().setRenderingFill(false); lyr.getBasicStyle().setAlpha(255); lyr.getBasicStyle().setLineWidth(lineWidth); lyr.setSynchronizingLineColor(false); lyr.getVertexStyle().setSize(vertexSize); lyr.getVertexStyle().setEnabled(vertexSize > 0); }
protected RenderableLayer getLayer() { for (Layer layer : getWwd().getModel().getLayers()) { if (layer.getName().contains("Renderable")) { return (RenderableLayer) layer; } } return null; }
private static void paintLayer( Graphics2D g, String layerName, Layers layers, WmsRequest request) { log.info("painting " + layerName); final Layer layer = layers.getLayer(layerName); if (layer != null) { layer.render(g, request); log.info("finished painting " + layerName); } else log.warn("no paintImage implementation for layer: " + layerName); }
/** * Returns metadata on the specified layer. * * @param layerId identifier of the layer, must not be <code>null</code> * @return metadata on the offered layers, may be <code>null</code> (no such layer) * @throws XMLStreamException if parsing the <code>wmts:Layer</code> elements in the capabilities * document fails */ public Layer getLayer(String layerId) throws XMLStreamException { List<Layer> layers = getLayers(); for (Layer layer : layers) { if (layer.getIdentifier().equals(layerId)) { return layer; } } return null; }
/** {@inheritDoc} */ public int compareTo(final Layer other) { if (other.getID() == getID()) { return 0; } else if (other.getID() > getID()) { return 1; } else { return -1; } }
/** Initializes the object. */ private void initialize() { this.allEntities = new MapEntities[3]; for (Layer layer : Layer.values()) { this.allEntities[layer.getId()] = new MapEntities(); } this.entitySelection = new MapEntitySelection(this); this.history = new MapEditorHistory(); }
/** * Sets the entities of the map. * * @param allEntities an array of 3 MapEntity sets: a set for each layer (this array is copied) */ public void setAllEntities(MapEntities[] allEntities) { for (Layer layer : Layer.values()) { this.allEntities[layer.getId()] = new MapEntities(allEntities[layer.getId()]); } setChanged(); notifyObservers(); }
protected Layer ghost() { Layer g = ghost != null ? ghost : createGhost(); g.setVisibility(false); Rectangle box = getBounds(false); g.setBounds(box, true); int h = bwrap.getHeight(); g.getChild(1).setHeight(h - 1, true); return g; }
@Override @SuppressWarnings("unchecked") public V attach(final Layer layer) { if (null == colExpButton && isExpandable()) { colExpButton = createExpandCollapseButton(); layer.add(colExpButton); } layer.add(getPalette()); return (V) this; }
@Override protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) { super.doGetRestorableState(rs, context); RestorableSupport.StateObject so = rs.addStateObject(context, "layers"); for (Layer layer : this.layers) { RestorableSupport.StateObject lso = rs.addStateObject(so, "layer"); layer.doGetRestorableState(rs, lso); } }
/** * Returns an entity, specifying its type and its name. * * @param type the type of entity * @param name the name of the entity * @return the entity, or null if there is no entity with this name */ public MapEntity getEntityWithName(EntityType type, String name) { for (Layer layer : Layer.values()) { MapEntity entity = allEntities[layer.getId()].getEntityWithName(type, name); if (entity != null) { return entity; } } return null; }
boolean intersects(final Area area, final double z_first, final double z_last) { for (int i = 0; i < n_points; i++) { final Layer la = layer_set.getLayer(p_layer[i]); if (la.getZ() >= z_first && la.getZ() <= z_last) { for (int k = 0; k < n_points; k++) { if (area.contains(p[0][k], p[1][k])) return true; } } } return false; }
/** * Returns the total number of active entities of the map. * * @return the total number of active entities of the map. */ public int getNbDynamicEntities() { int nbDynamicEntities = 0; // count the dynamic entities of each layer for (Layer layer : Layer.values()) { nbDynamicEntities += allEntities[layer.getId()].getNbDynamicEntities(); } return nbDynamicEntities; }
/** * Returns the total number of entities of the map. * * @return the total number of entities of the map. */ public int getNbEntities() { int nbEntities = 0; // count the entities of each layer for (Layer layer : Layer.values()) { nbEntities += allEntities[layer.getId()].size(); } return nbEntities; }
/** * Applies Camera transformations and draws all the Layers in this World. * * @param canvas The Canvas onto which the World will be drawn. */ public void draw(Canvas canvas) { canvas.save(); canvas.translate(-camera.getPosition().getX(), -camera.getPosition().getY()); for (Layer l : layers) { l.draw(canvas, camera.getBoundingBox()); } canvas.restore(); }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; for (Layer layer : layers) try { layer.paint(g2, this); } catch (Exception e) { e.printStackTrace(); } }
/** * Give a prediction based on some input. * * @param input The input to the neural network which is equal in size to the number of input * neurons. * @return The output of the neural network. */ public Matrix predict(Matrix input) { if (input.getNumRows() != layers.get(0).getLayerSize().getInputSize()) { throw new InvalidParameterException( "Input size did not match the input size of the first layer"); } Matrix modInput = (Matrix) input.clone(); for (Layer l : layers) { modInput = l.activate(modInput); } return modInput; }
Map<String, String> getInfos(Date time, WmsRequest request, Point point, String mimeType) { Map<String, String> map = new HashMap<String, String>(); for (String layerName : request.getLayers()) { Layer layer = layers.getLayer(layerName); if (layer != null) { String info = layer.getInfo(time, request, point, mimeType); if (info != null) map.put(layerName, info); } else log.warn("no getInfo implementation for layer: " + layerName); } return map; }