use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class ConnectorView method getModeController.
private ModeController getModeController() {
NodeView nodeView = source;
if (source == null) {
nodeView = target;
}
final MapView mapView = nodeView.getMap();
return mapView.getModeController();
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class ExternalResource method setZoom.
public void setZoom(final float r) {
zoom = r;
for (final NodeView nodeView : viewers) {
final JComponent viewer = nodeView.getContent(ViewerController.VIEWER_POSITION);
final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, viewer);
final Dimension preferredSize = ((ScalableComponent) viewer).getOriginalSize();
preferredSize.width = (int) (preferredSize.width * r);
preferredSize.height = (int) (preferredSize.height * r);
preferredSize.width = mapView.getZoomed(preferredSize.width);
preferredSize.height = mapView.getZoomed(preferredSize.height);
((ScalableComponent) viewer).setFinalViewerSize(preferredSize);
viewer.revalidate();
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class NodeHistory method go.
private void go(final boolean back) {
final NodeHolder lastNodeHolder = currentNodeHolder;
if (back) {
if (canGoBack()) {
nodeIterator.previous();
nodeIterator.previous();
currentNodeHolder = nodeIterator.next();
} else {
backAction.setEnabled(false);
return;
}
} else {
if (canGoForward()) {
currentNodeHolder = nodeIterator.next();
} else {
forwardAction.setEnabled(false);
return;
}
}
if (lastNodeHolder.equals(currentNodeHolder)) {
go(back);
return;
}
final NodeModel toBeSelected = currentNodeHolder.getNode();
if (removed(toBeSelected)) {
currentNodeHolder = lastNodeHolder;
go(back);
return;
}
boolean changeModule = false;
MapView newModule = null;
if (lastNodeHolder.getHoldMapView() != currentNodeHolder.getHoldMapView()) {
changeModule = true;
newModule = currentNodeHolder.getMapView();
if (newModule == null) {
nodeIterator.remove();
go(back);
return;
}
}
final boolean fChangeModule = changeModule;
final MapView newView;
if (fChangeModule) {
newView = newModule;
final Controller controller = newView.getModeController().getController();
final IMapViewManager mapViewManager = controller.getMapViewManager();
final boolean res = mapViewManager.changeToMapView(newView);
if (!res) {
LogUtils.warn("Can't change to map mapView " + newView);
return;
}
} else {
newView = currentNodeHolder.getHoldMapView();
}
if (!toBeSelected.isRoot()) {
newView.getModeController().getMapController().setFolded(toBeSelected.getParentNode(), false);
}
newView.getModeController().getMapController().select(toBeSelected);
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class ViewerLayoutManager method layoutContainer.
public void layoutContainer(final Container parent) {
if (!parent.isPreferredSizeSet()) {
throw new IllegalStateException("preferred size not set for " + parent);
}
final Dimension preferredSize = parent.getPreferredSize();
final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, parent);
if (mapView == null) {
return;
}
final float newZoom = mapView.getZoom();
if (zoom != newZoom) {
final float ratio = newZoom / zoom;
preferredSize.width = (int) (Math.rint(preferredSize.width * ratio));
preferredSize.height = (int) (Math.rint(preferredSize.height * ratio));
parent.setPreferredSize(preferredSize);
zoom = newZoom;
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class NodeHolder method getMapView.
MapView getMapView() {
final MapView mapView = mMapView.get();
final Controller controller = mapView.getModeController().getController();
final MapViewController mapViewManager = (MapViewController) controller.getMapViewManager();
for (final MapView m : mapViewManager.getMapViewVector()) {
if (m == mapView) {
return mapView;
}
}
return null;
}
Aggregations