use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class ExportSvg method export.
public void export(MapModel map, File chosenFile) {
if (!ExportController.getContoller().checkCurrentMap(map)) {
return;
}
try {
final MapView view = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
if (view == null) {
return;
}
Controller.getCurrentController().getViewController().setWaitingCursor(true);
final SVGGraphics2D g2d = fillSVGGraphics2D(view);
final FileOutputStream bos = new FileOutputStream(chosenFile);
final BufferedOutputStream bufStream = new BufferedOutputStream(bos);
final OutputStreamWriter osw = new OutputStreamWriter(bufStream, "UTF-8");
g2d.stream(osw);
osw.flush();
bos.flush();
bos.close();
} catch (final Exception ex) {
org.freeplane.core.util.LogUtils.warn(ex);
UITools.errorMessage(ex.getLocalizedMessage());
} finally {
Controller.getCurrentController().getViewController().setWaitingCursor(false);
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class LastOpenedList method updateLastVisitedNodeId.
private void updateLastVisitedNodeId(final Component mapView) {
if (!(mapView instanceof MapView))
return;
final NodeView selected = ((MapView) mapView).getSelected();
final RecentFile recentFile = findRecentFileByMapModel(getMapModel(mapView));
if (selected != null && recentFile != null) {
NodeModel selectedNode = selected.getModel();
// if a map has never been visited restoration of the selection has not yet taken place
if (!selectedNode.isRoot())
recentFile.lastVisitedNodeId = selectedNode.getID();
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class AttributeTable method updateComponentFontAndColors.
private void updateComponentFontAndColors(final JComponent c) {
final NodeView nodeView = attributeView.getNodeView();
final MapView mapView = nodeView.getMap();
final ModeController modeController = mapView.getModeController();
final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final Font font = style.getFont(attributeStyleNode);
c.setFont(font.deriveFont(UITools.FONT_SCALE_FACTOR * font.getSize2D()));
if (!SwingUtilities.isDescendingFrom(this, nodeView)) {
return;
}
final Color backgroundColor = NodeStyleModel.getBackgroundColor(attributeStyleNode);
if (backgroundColor != null) {
c.setOpaque(true);
c.setBackground(backgroundColor);
} else {
c.setBackground(nodeView.getBackgroundColor());
c.setOpaque(false);
}
c.setForeground(style.getColor(attributeStyleNode));
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class AttributeTable method updateGridColor.
private void updateGridColor() {
final NodeView nodeView = attributeView.getNodeView();
if (!SwingUtilities.isDescendingFrom(this, nodeView))
return;
final MapView mapView = nodeView.getMap();
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final EdgeModel edge = EdgeModel.getModel(attributeStyleNode);
if (edge != null) {
final Color edgeColor = edge.getColor();
setGridAndBorderColor(edgeColor);
} else
this.gridColor = null;
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class MNodeMouseWheelListener method mouseWheelMoved.
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (!e.isAltDown()) {
super.mouseWheelMoved(e);
return;
}
final MainView view = (MainView) e.getComponent();
final MapView map = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, view);
if (map.usesLayoutSpecificMaxNodeWidth())
return;
final int wheelRotation = e.getWheelRotation();
final NodeView nodeView = view.getNodeView();
if (!nodeView.isSelected())
map.selectAsTheOnlyOneSelected(nodeView);
final double factor = e.isControlDown() ? 1 : 6 * LengthUnits.pt.factor();
double newZoomedWidth = Math.max((view.getWidth() - wheelRotation * factor) / map.getZoom(), 0);
final IMapSelection selection = Controller.getCurrentController().getSelection();
Quantity<LengthUnits> newZoomedWidthQuantity = LengthUnits.pixelsInPt(newZoomedWidth);
final ModeController modeController = map.getModeController();
final MNodeStyleController styleController = (MNodeStyleController) modeController.getExtension(NodeStyleController.class);
selection.keepNodePosition(nodeView.getModel(), 0f, 0f);
for (final NodeModel node : selection.getSelection()) {
styleController.setMinNodeWidth(node, newZoomedWidthQuantity);
styleController.setMaxNodeWidth(node, newZoomedWidthQuantity);
}
}
Aggregations