use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class PresentationPngExporter method exportSlide.
private void exportSlide(File presentationDirectory, Slide slide) {
final NodeModel placedNode = slide.getCurrentPlacedNode();
if (placedNode != null)
slide.apply(presentationZoomFactor);
else
slide.apply(1f);
mapViewComponent.validate();
mapViewComponent.setSize(mapViewComponent.getPreferredSize());
File exportFile = new File(presentationDirectory, FileUtils.validFileNameOf(slide.getName()) + ".png");
final ExportToImage exporter = ExportToImage.toPNG();
final Controller controller = Controller.getCurrentController();
final MapModel map = controller.getMap();
if (placedNode != null) {
final Dimension slideSize;
if (ResourceController.getResourceController().getBooleanProperty(SWITCH_TO_FULL_SCREEN_PROPERTY))
slideSize = mapViewComponent.getGraphicsConfiguration().getBounds().getSize();
else
slideSize = SwingUtilities.getWindowAncestor(mapViewComponent).getSize();
exporter.export(map, slideSize, placedNode, slide.getPlacedNodePosition(), exportFile);
} else
exporter.export(map, exportFile);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class Slide method getSelectedNodes.
private ArrayList<NodeModel> getSelectedNodes(boolean onlyVisible) {
MapModel map = getMap();
ArrayList<NodeModel> selectedNodes = new ArrayList<>(selectedNodeIds.size());
for (String id : selectedNodeIds) {
NodeModel node = map.getNodeForID(id);
if (node != null && (!onlyVisible || node.isVisible()))
selectedNodes.add(node);
}
return selectedNodes;
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class SlideEditorController method createPlacesSelectedNodeToggleButton.
private JToggleButton createPlacesSelectedNodeToggleButton() {
final JToggleButton checkBoxOnlySpecificNodes = createToggleButtonWithIconAndLabel("PlaceSelectedNodeOnSlide.icon", "slide.placenode");
checkBoxOnlySpecificNodes.setAlignmentX(Component.CENTER_ALIGNMENT);
checkBoxOnlySpecificNodes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String centeredNodeId = slide.getPlacedNodeId();
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (centeredNodeId == null) {
final NodeModel selected = selection.getSelected();
if (selected != null) {
UndoableSlide.of(slide).setPlacedNodeId(selected.getID());
setNodePlacementControlsEnabled(true, slide.getPlacedNodePosition());
} else {
UndoableSlide.of(slide).setPlacedNodeId(null);
setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
}
} else {
UndoableSlide.of(slide).setPlacedNodeId(null);
setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
final MapModel map = Controller.getCurrentController().getMap();
final NodeModel node = map.getNodeForID(centeredNodeId);
if (node != null)
selection.selectAsTheOnlyOneSelected(node);
}
checkBoxOnlySpecificNodes.setSelected(slide.getPlacedNodeId() != null);
}
});
return checkBoxOnlySpecificNodes;
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class PresentationController method addMapSelectionListener.
private void addMapSelectionListener() {
IMapSelectionListener mapSelectionListener = new IMapSelectionListener() {
@Override
public void beforeMapChange(MapModel oldMap, MapModel newMap) {
}
@Override
public void afterMapChange(MapModel oldMap, MapModel newMap) {
presentationState.stopPresentation();
if (newMap != null && Controller.getCurrentModeController() == modeController)
presentationEditorController.setPresentations(getPresentations(newMap).presentations);
else
presentationEditorController.setPresentations(null);
}
};
modeController.getController().getMapViewManager().addMapSelectionListener(mapSelectionListener);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class UrlManager method loadOtherURI.
private void loadOtherURI(URI uri, final boolean hasFreeplaneFileExtension) {
try {
if (!uri.isAbsolute()) {
URI absoluteUri = getAbsoluteUri(uri);
if (absoluteUri == null) {
final MapModel map = Controller.getCurrentController().getMap();
if (map.getURL() == null)
UITools.errorMessage(TextUtils.getText("map_not_saved"));
else
UITools.errorMessage(TextUtils.format("link_not_found", String.valueOf(uri)));
return;
}
uri = absoluteUri;
}
// DOCEAR: mindmaps can be linked in a mindmap --> therefore project-relative-paths are possible
if (!asList(FILE_SCHEME, SMB_SCHEME, FREEPLANE_SCHEME).contains(uri.getScheme())) {
try {
uri = uri.toURL().openConnection().getURL().toURI().normalize();
} catch (Exception e) {
// ignore all exceptions due to unknown protocols
}
}
try {
if (hasFreeplaneFileExtension) {
FreeplaneUriConverter freeplaneUriConverter = new FreeplaneUriConverter();
final URL url = freeplaneUriConverter.freeplaneUrl(uri);
final ModeController modeController = Controller.getCurrentModeController();
modeController.getMapController().newMap(url);
return;
}
Controller.getCurrentController().getViewController().openDocument(uri);
} catch (final Exception e) {
LogUtils.warn("link " + uri + " not found", e);
UITools.errorMessage(TextUtils.format("link_not_found", uri.toString()));
}
return;
} catch (final MalformedURLException ex) {
LogUtils.warn("URL " + uri + " not found", ex);
UITools.errorMessage(TextUtils.format("link_not_found", uri));
}
}
Aggregations