Search in sources :

Example 1 with RenderableLayer

use of gov.nasa.worldwind.layers.RenderableLayer in project mapton by trixon.

the class GeoRenderer method load.

@Override
protected void load(MCoordinateFile coordinateFile) {
    mCooTrans = coordinateFile.getCooTrans();
    var layer = new RenderableLayer();
    Geo geo = new Geo();
    try {
        geo.read(coordinateFile.getFile());
        renderPoints(layer, geo.getPoints());
        System.out.println(geo.getLines().size());
        // Dynamic transform
        // Create Points
        // Create Lines
        System.out.println(geo.toString());
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    addLayer(coordinateFile, layer);
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) Geo(se.trixon.almond.util.io.Geo) IOException(java.io.IOException)

Example 2 with RenderableLayer

use of gov.nasa.worldwind.layers.RenderableLayer in project mapton by trixon.

the class LayerView method getParent.

private CheckBoxTreeItem<Layer> getParent(CheckBoxTreeItem<Layer> parent, String category) {
    String[] categorySegments = StringUtils.split(category, "/");
    StringBuilder sb = new StringBuilder();
    for (String segment : categorySegments) {
        sb.append(segment);
        String path = sb.toString();
        if (mLayerParents.containsKey(path)) {
            parent = mLayerParents.get(path);
        } else {
            Layer layer = new RenderableLayer();
            layer.setValue(WWHelper.KEY_LAYER_CATEGORY, path);
            layer.setName(segment);
            parent.getChildren().add(parent = mLayerParents.computeIfAbsent(sb.toString(), k -> new CheckBoxTreeItem<>(layer)));
        }
        sb.append("/");
    }
    return parent;
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) Layer(gov.nasa.worldwind.layers.Layer) RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer)

Example 3 with RenderableLayer

use of gov.nasa.worldwind.layers.RenderableLayer in project hortonmachine by TheHortonMachine.

the class GeopaparazziController method init.

@SuppressWarnings({ "serial" })
private void init() {
    _infoArea = new JTextPane();
    // _infoArea.setDocument(new SqlDocument());
    _infoArea.setContentType("text/html");
    _infoArea.setEditable(false);
    _infoScroll.setViewportView(_infoArea);
    // _infoScroll.setMinimumSize(new Dimension(10, 200));
    _chartHolder.setLayout(new BorderLayout());
    _loadFolderButton.setIcon(ImageCache.getInstance().getImage(ImageCache.REFRESH));
    _loadFolderButton.setText("");
    _loadFolderButton.setPreferredSize(preferredButtonSize);
    _loadFolderButton.addActionListener(e -> {
        final File geopaparazziFolder = new File(_projectsFolderTextfield.getText());
        if (!geopaparazziFolder.exists()) {
            GuiUtilities.showWarningMessage(this, null, "The projects folder doesn't exist.");
            return;
        }
        File[] projectFiles = GeopaparazziUtilities.getGeopaparazziFiles(geopaparazziFolder);
        try {
            projectInfos = readProjectInfos(projectFiles);
            layoutTree(projectInfos, false);
            _filterTextfield.setText("");
        } catch (Exception e1) {
            Logger.INSTANCE.insertError("", "error", e1);
        }
    });
    _projectsFolderBrowseButton.setPreferredSize(preferredButtonSize);
    _projectsFolderBrowseButton.addActionListener(e -> {
        File[] openFiles = guiBridge.showOpenDirectoryDialog("Open projects folder", PreferencesHandler.getLastFile());
        if (openFiles != null && openFiles.length > 0) {
            try {
                PreferencesHandler.setLastPath(openFiles[0].getAbsolutePath());
            } catch (Exception e1) {
                Logger.INSTANCE.insertError("", "ERROR", e1);
            }
        } else {
            return;
        }
        _projectsFolderTextfield.setText(openFiles[0].getAbsolutePath());
    });
    String lastSavedPath = prefsMap.get(GuiBridgeHandler.LAST_GP_PROJECTS_PATH);
    _projectsFolderTextfield.setText(lastSavedPath);
    _filterTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            String filterText = _filterTextfield.getText().toLowerCase();
            final List<ProjectInfo> filtered = new ArrayList<ProjectInfo>();
            if (filterText == null) {
                filtered.addAll(projectInfos);
            } else {
                for (ProjectInfo projectInfo : projectInfos) {
                    if (projectInfo.fileName.toLowerCase().contains(filterText) || projectInfo.metadata.toLowerCase().contains(filterText)) {
                        filtered.add(projectInfo);
                    }
                }
            }
            layoutTree(filtered, false);
        }
    });
    addComponentListener(new ComponentListener() {

        public void componentShown(ComponentEvent e) {
        }

        public void componentResized(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
        }

        public void componentHidden(ComponentEvent e) {
            onClose();
        }
    });
    try {
        _databaseTreeView.setMinimumSize(new Dimension(300, 200));
        addJtreeDragNDrop();
        addJtreeContextMenu();
        _databaseTree.setRootVisible(false);
        _databaseTree.setCellRenderer(new DefaultTreeCellRenderer() {

            @Override
            public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
                if (value instanceof ProjectInfo) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.DATABASE));
                } else if (value instanceof Image) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.DBIMAGE));
                } else if (value instanceof GpsLog) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.GEOM_LINE));
                } else if (value instanceof Note) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.NOTE));
                }
                return this;
            }
        });
        _databaseTree.addTreeSelectionListener(new TreeSelectionListener() {

            public void valueChanged(TreeSelectionEvent evt) {
                TreePath[] paths = evt.getPaths();
                currentSelectedProject = null;
                currentSelectedImage = null;
                currentSelectedNote = null;
                currentSelectedGpsLog = null;
                _chartHolder.removeAll();
                if (paths.length > 0) {
                    Object selectedItem = paths[0].getLastPathComponent();
                    if (selectedItem instanceof ProjectInfo) {
                        currentSelectedProject = (ProjectInfo) selectedItem;
                        selectProjectInfo(currentSelectedProject);
                        Logger.INSTANCE.insertDebug("", "Selected project: " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof Image) {
                        currentSelectedImage = (Image) selectedItem;
                        currentSelectedProject = getProjectForImage(currentSelectedImage);
                        selectImage(currentSelectedImage);
                        Logger.INSTANCE.insertDebug("", "Selected image: " + currentSelectedImage.getName() + " of project " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof GpsLog) {
                        currentSelectedGpsLog = (GpsLog) selectedItem;
                        currentSelectedProject = getProjectForGpsLog(currentSelectedGpsLog);
                        selectGpsLog(currentSelectedGpsLog);
                        Logger.INSTANCE.insertDebug("", "Selected gpslog: " + currentSelectedGpsLog.text + " of project " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof Note) {
                        currentSelectedNote = (Note) selectedItem;
                        currentSelectedProject = getProjectForNote(currentSelectedNote);
                        selectNote(currentSelectedNote);
                        Logger.INSTANCE.insertDebug("", "Selected note: " + currentSelectedNote.simpleText + " of project " + currentSelectedProject.fileName);
                    }
                }
            }
        });
        _databaseTree.setVisible(false);
    } catch (Exception e1) {
        Logger.INSTANCE.insertError("", "Error", e1);
    }
    layoutTree(null, false);
    Component wwjPanelComponent = null;
    try {
        wwjPanelComponent = NwwPanel.createNwwPanel(true);
    } catch (UnsatisfiedLinkError e1) {
    // ignore
    }
    if (wwjPanelComponent instanceof NwwPanel) {
        _nwwHolder.setLayout(new BorderLayout());
        _nwwHolder.add(wwjPanelComponent, BorderLayout.CENTER);
        wwjPanel = (NwwPanel) wwjPanelComponent;
        wwjPanel.addOsmLayer();
        geopapDataLayer = new RenderableLayer();
        wwjPanel.addLayer(geopapDataLayer);
    } else {
        _nwwHolderFrame.setVisible(false);
        _chartHolderFrame.setVisible(false);
        setPreferredSize(new Dimension(400, 600));
    }
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) ComponentListener(java.awt.event.ComponentListener) KeyAdapter(java.awt.event.KeyAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) LineString(org.locationtech.jts.geom.LineString) Image(org.hortonmachine.gears.io.geopaparazzi.geopap4.Image) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) KeyEvent(java.awt.event.KeyEvent) JTextPane(javax.swing.JTextPane) BorderLayout(java.awt.BorderLayout) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) DaoGpsLog(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog) GpsLog(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsLog) Dimension(java.awt.Dimension) GpsPoint(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsPoint) NwwPanel(org.hortonmachine.nww.gui.NwwPanel) JTree(javax.swing.JTree) Note(org.hortonmachine.gears.io.geopaparazzi.geopap4.Note) ComponentEvent(java.awt.event.ComponentEvent) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) File(java.io.File)

Example 4 with RenderableLayer

use of gov.nasa.worldwind.layers.RenderableLayer in project mapton by trixon.

the class KmlRenderer method load.

@Override
protected void load(MCoordinateFile coordinateFile) {
    var layer = new RenderableLayer();
    try {
        var kmlRoot = KMLRoot.createAndParse(coordinateFile.getFile());
        layer.addRenderable(new KMLController(kmlRoot));
        addLayer(coordinateFile, layer);
    } catch (IOException | XMLStreamException ex) {
        Exceptions.printStackTrace(ex);
    }
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) KMLController(gov.nasa.worldwind.ogc.kml.impl.KMLController) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Example 5 with RenderableLayer

use of gov.nasa.worldwind.layers.RenderableLayer in project mapton by trixon.

the class LayerView method createUI.

private void createUI() {
    var rootLayer = new RenderableLayer();
    rootLayer.setName("");
    mRootItem = new CheckBoxTreeItem<>(rootLayer);
    mTreeView = new CheckTreeView<>(mRootItem);
    mCheckModel = mTreeView.getCheckModel();
    mTreeView.setShowRoot(false);
    mTreeView.setCellFactory(param -> new LayerTreeCell());
    mOptionsPopOver = new MOptionsPopOver();
    mOptionsPopOver.setArrowLocation(PopOver.ArrowLocation.LEFT_CENTER);
    mOptionsPopOver.setOnShowing(windowEvent -> {
        var layerBundle = (LayerBundle) getSelectedTreeItem().getValue().getValue("layerBundle");
        mOptionsPopOver.setContentNode(layerBundle.getOptionsView());
    });
    mOptionsAction = mOptionsPopOver.getAction();
    mOptionsAction.setDisabled(true);
    var maskerPane = new MaskerPane();
    maskerPane.setText(MDict.LOADING_LAYERS.toString());
    maskerPane.setProgress(-1);
    setCenter(maskerPane);
    mFilterTextField = TextFields.createClearableTextField();
    mFilterTextField.setPromptText(Dict.LAYER_SEARCH.toString());
    mFilterTextField.setMinWidth(20);
    final int iconSize = (int) (getIconSizeToolBarInt() * 0.8);
    var selectActionGroup = new ActionGroup(Dict.SHOW.toString(), MaterialIcon._Image.REMOVE_RED_EYE.getImageView(iconSize), new Action(Dict.SHOW.toString(), (event) -> {
        setChecked(mRootItem, true);
    }), new Action(Dict.HIDE.toString(), (event) -> {
        setChecked(mRootItem, false);
    }), ActionUtils.ACTION_SEPARATOR, new Action(Dict.EXPAND.toString(), (event) -> {
        setExpanded(mRootItem, true);
    }), new Action(Dict.COLLAPSE.toString(), (event) -> {
        setExpanded(mRootItem, false);
    }));
    Collection<? extends Action> actions = Arrays.asList(selectActionGroup, mOptionsAction);
    mToolBar = ActionUtils.createToolBar(actions, ActionUtils.ActionTextBehavior.HIDE);
    FxHelper.adjustButtonWidth(mToolBar.getItems().stream(), iconSize);
    FxHelper.undecorateButtons(mToolBar.getItems().stream());
    FxHelper.slimToolBar(mToolBar);
    var topBorderPane = new BorderPane(mFilterTextField);
    topBorderPane.setRight(mToolBar);
    mToolBar.setMinWidth(iconSize * 4.8);
    setTop(topBorderPane);
    var optionsItem = new MenuItem(Dict.OPTIONS.toString());
    optionsItem.disableProperty().bind(mOptionsAction.disabledProperty());
    optionsItem.setOnAction(actionEvent -> {
        mOptionsAction.handle(new ActionEvent(getOptionsToolBarButton(), this));
    });
    mContextMenu = new ContextMenu(optionsItem);
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) Arrays(java.util.Arrays) ActionUtils(org.controlsfx.control.action.ActionUtils) StringHelper(se.trixon.almond.util.StringHelper) MaterialIcon(se.trixon.almond.util.icons.material.MaterialIcon) ActionGroup(org.controlsfx.control.action.ActionGroup) StringUtils(org.apache.commons.lang3.StringUtils) MaskerPane(org.controlsfx.control.MaskerPane) Dict(se.trixon.almond.util.Dict) ListChangeListener(javafx.collections.ListChangeListener) Layer(gov.nasa.worldwind.layers.Layer) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) MOptionsPopOver(org.mapton.api.ui.MOptionsPopOver) PopOver(org.controlsfx.control.PopOver) WWHelper(org.mapton.worldwind.api.WWHelper) SortedList(javafx.collections.transformation.SortedList) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) ButtonBase(javafx.scene.control.ButtonBase) MKey(org.mapton.api.MKey) Collection(java.util.Collection) Set(java.util.Set) Platform(javafx.application.Platform) CheckModel(org.controlsfx.control.CheckModel) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) LayerBundle(org.mapton.worldwind.api.LayerBundle) NbPreferences(org.openide.util.NbPreferences) MDict(org.mapton.api.MDict) MouseButton(javafx.scene.input.MouseButton) TreeItem(javafx.scene.control.TreeItem) Action(org.controlsfx.control.action.Action) FXCollections(javafx.collections.FXCollections) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashSet(java.util.HashSet) TextFields(org.controlsfx.control.textfield.TextFields) Mapton(org.mapton.api.Mapton) DelayedResetRunner(se.trixon.almond.util.fx.DelayedResetRunner) MActivatable(org.mapton.api.MActivatable) ToolBar(javafx.scene.control.ToolBar) CheckTreeView(org.controlsfx.control.CheckTreeView) RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) CheckBoxTreeCell(javafx.scene.control.cell.CheckBoxTreeCell) Preferences(java.util.prefs.Preferences) CheckBoxTreeItem(javafx.scene.control.CheckBoxTreeItem) ActionEvent(javafx.event.ActionEvent) TreeMap(java.util.TreeMap) Mapton.getIconSizeToolBarInt(org.mapton.api.Mapton.getIconSizeToolBarInt) ObservableValue(javafx.beans.value.ObservableValue) Comparator(java.util.Comparator) Collections(java.util.Collections) FxHelper(se.trixon.almond.util.fx.FxHelper) LayerBundle(org.mapton.worldwind.api.LayerBundle) Action(org.controlsfx.control.action.Action) BorderPane(javafx.scene.layout.BorderPane) ActionEvent(javafx.event.ActionEvent) MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) MaskerPane(org.controlsfx.control.MaskerPane) ActionGroup(org.controlsfx.control.action.ActionGroup) MOptionsPopOver(org.mapton.api.ui.MOptionsPopOver)

Aggregations

RenderableLayer (gov.nasa.worldwind.layers.RenderableLayer)5 Layer (gov.nasa.worldwind.layers.Layer)2 IOException (java.io.IOException)2 KMLController (gov.nasa.worldwind.ogc.kml.impl.KMLController)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 ComponentEvent (java.awt.event.ComponentEvent)1 ComponentListener (java.awt.event.ComponentListener)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1