/** Convert gradient sky to color sky. */ protected void setupSky() { // Change atmosphere SkyGradientLayer for SkyColorLayer LayerList layers = getWWD().getModel().getLayers(); for (int i = 0; i < layers.size(); i++) { if (layers.get(i) instanceof SkyGradientLayer) layers.set(i, new SkyColorLayer()); } }
/** * Insert layer just beneath the Compass layer. * * @param layer - layer to insert */ protected void insertBeforeCompass(Layer layer) { // Insert the layer into the layer list just before the compass. int compassPosition = 0; LayerList layers = getWWD().getModel().getLayers(); for (Layer l : layers) { if (l instanceof CompassLayer) compassPosition = layers.indexOf(l); } layers.add(compassPosition, layer); }
/** * Insert the given Layer before or after the first occurrence of the given layer type. * * @param layer The layer to insert * @param layerType The type of layer to insert before or after * @param insertBefore Boolean that if true, will all insertion before the given type and if * false, will insert after the type has been encountered. */ public void insertAtLayer(Layer layer, Class<?> layerType, boolean insertBefore) { LayerList layers = getWWD().getModel().getLayers(); int offset = insertBefore ? 0 : 1; for (Layer aLayer : layers) { if (aLayer.getClass().isInstance(layerType)) { layers.add(layers.indexOf(aLayer) + offset, layer); break; } } }
public void enable() { this.getShape().setStartPosition(null); LayerList layers = this.getWwd().getModel().getLayers(); if (!layers.contains(this.getLayer())) layers.add(this.getLayer()); if (!this.getLayer().isEnabled()) this.getLayer().setEnabled(true); this.setArmed(true); this.getWwd().addRenderingListener(this); this.getWwd().addSelectListener(this); this.getWwd().getInputHandler().addMouseListener(this); this.getWwd().getInputHandler().addMouseMotionListener(this); this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); }
/** * Insert the given layer before or after the first occurrence of the given layer object * * @param layer The layer to insert * @param targetLayer The layer before or after which the given layer will be inserted * @param insertBefore Boolean that if true, will all insertion before the given type and if * false, will insert after the type has been encountered. */ public void insertAtLayer(Layer layer, Layer targetLayer, boolean insertBefore) { LayerList layers = getWWD().getModel().getLayers(); int offset = insertBefore ? 0 : 1; layers.add(layers.indexOf(targetLayer) + offset, layer); }
/** * Remove a layer from the map * * @param layer layer to remove from the map */ public void removeLayer(Layer layer) { LayerList layers = getWWD().getModel().getLayers(); layers.remove(layer); }
public TestlocWorldFrame(String wdPath) { mapDirPath = wdPath; initFilelist(); Model roundModel = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); globeMapPanel = new MapPanel(roundModel, true); roundModel.getLayers().getLayerByName("Bing Imagery").setEnabled(true); LayerPanel layerPanel = new LayerPanel(globeMapPanel.wwd); globeDisplayAdapter = new DisplayAdapter(globeMapPanel.wwd, pointBuilderListener, MouseEvent.BUTTON1, 5, true); mapRenderLayer = new RenderableLayer(); mapRenderLayer.setName("Surface Images"); mapRenderLayer.setPickEnabled(false); LayerList layers = new LayerList(); layers.add(mapRenderLayer); Model flatModel = new BasicModel(new EarthFlat(), layers); ((EarthFlat) flatModel.getGlobe()).setProjection(FlatGlobe.PROJECTION_LAT_LON); mapMapPanel = new MapPanel(flatModel, false); mapDisplayAdapter = new DisplayAdapter( mapMapPanel.wwd, markerBuilderListener, MouseEvent.BUTTON3, 50000, false); try { globeMapPanel.add(new GazetteerPanel(globeMapPanel.wwd, null), BorderLayout.NORTH); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { e.printStackTrace(); System.exit(1); } mapSelectionList = new JList<String>(trackNames); mapSelectionList.addListSelectionListener(listListener); JLabel lblStepsize = new JLabel("Stepsize:"); textFieldStepsize = new JTextField(); textFieldStepsize.setText("5"); btnStep = new JButton("Step"); btnStep.addMouseListener(stepListener); btnStepToMarker = new JButton("to Marker"); btnStepToMarker.addMouseListener(notImplementedListener); slider = new JSlider(); slider.setValue(0); slider.addMouseListener(sliderListener); JLabel lblDstFallofExp = new JLabel("Distance Fallof:"); textFieldDistFallofExp = new JTextField(); textFieldDistFallofExp.setText(String.valueOf(7)); JLabel lblTriDissimilarity = new JLabel("Tri Dissimilarity:"); textFieldTriDissimilarity = new JTextField(); textFieldTriDissimilarity.setText(String.valueOf(0.50)); JLabel lblMinTriAngle = new JLabel("Min Tri Angle:"); textFieldMinTriAngle = new JTextField(); textFieldMinTriAngle.setText(String.valueOf(4.2)); JLabel lblBadTriPen = new JLabel("Bad Tri Penalty:"); textFieldBadTriPen = new JTextField(); textFieldBadTriPen.setText(String.valueOf(0.10)); btnDisplayTriangles = new JButton("Display Triangles"); btnDisplayTriangles.addMouseListener(notImplementedListener); btnRefresh = new JButton("Refresh"); btnRefresh.addMouseListener(parameterRefreshListener); tglbtnMouseMode = new JToggleButton("Mode: Move"); tglbtnMouseMode.addMouseListener(toggleAction); JButton btnNewFile = new JButton("New File"); btnNewFile.addMouseListener(newFileListener); JButton btnSaveFile = new JButton("Save File"); btnSaveFile.addMouseListener(saveFileListener); // Window Builder generated stuff JPanel settings = new JPanel(); GroupLayout groupLayout = new GroupLayout(settings); groupLayout.setHorizontalGroup( groupLayout .createParallelGroup(Alignment.TRAILING) .addGroup( groupLayout .createSequentialGroup() .addContainerGap() .addGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addComponent(lblStepsize) .addGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addGap(421) .addComponent(lblTriDissimilarity) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( textFieldTriDissimilarity, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblBadTriPen) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( textFieldBadTriPen, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnRefresh) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewFile) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnSaveFile)) .addGroup( groupLayout .createSequentialGroup() .addGap(12) .addComponent( textFieldStepsize, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblDstFallofExp) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( textFieldDistFallofExp, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblMinTriAngle) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( textFieldMinTriAngle, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)))) .addGroup( groupLayout .createSequentialGroup() .addComponent( btnStep, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnStepToMarker) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( tglbtnMouseMode, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( btnDisplayTriangles, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent( slider, GroupLayout.DEFAULT_SIZE, 1062, Short.MAX_VALUE))) .addContainerGap())); groupLayout.setVerticalGroup( groupLayout .createParallelGroup(Alignment.LEADING) .addGroup( groupLayout .createSequentialGroup() .addContainerGap() .addGroup( groupLayout .createParallelGroup(Alignment.BASELINE) .addComponent(lblStepsize) .addComponent( textFieldStepsize, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblDstFallofExp) .addComponent( textFieldDistFallofExp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblMinTriAngle) .addComponent( textFieldMinTriAngle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblTriDissimilarity) .addComponent( textFieldTriDissimilarity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblBadTriPen) .addComponent( textFieldBadTriPen, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btnRefresh) .addComponent(btnNewFile) .addComponent(btnSaveFile)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup( groupLayout .createParallelGroup(Alignment.TRAILING) .addGroup( groupLayout .createParallelGroup(Alignment.BASELINE) .addComponent(btnStep) .addComponent(btnStepToMarker) .addComponent(tglbtnMouseMode) .addComponent(btnDisplayTriangles)) .addComponent( slider, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))); settings.setLayout(groupLayout); JSplitPane globeSplit = new JSplitPane(); globeSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT); globeSplit.setLeftComponent(layerPanel); globeSplit.setRightComponent(globeMapPanel); globeSplit.setOneTouchExpandable(true); globeSplit.setContinuousLayout(true); globeSplit.setDividerLocation(0); JSplitPane imgSplit = new JSplitPane(); imgSplit.setOrientation(JSplitPane.HORIZONTAL_SPLIT); imgSplit.setLeftComponent(mapMapPanel); imgSplit.setRightComponent(mapSelectionList); imgSplit.setOneTouchExpandable(true); imgSplit.setContinuousLayout(true); JSplitPane layer2Split = new JSplitPane(); layer2Split.setOrientation(JSplitPane.HORIZONTAL_SPLIT); layer2Split.setLeftComponent(globeSplit); layer2Split.setRightComponent(imgSplit); layer2Split.setOneTouchExpandable(true); layer2Split.setContinuousLayout(true); layer2Split.setResizeWeight(0.5); this.add(settings, BorderLayout.NORTH); this.add(layer2Split, BorderLayout.CENTER); this.pack(); this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); enableSettingsMode(false); }