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);
}
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;
}
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));
}
}
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);
}
}
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);
}
Aggregations