use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class PrintController method print.
public void print(Printable mapView, boolean showDlg) throws PrinterException {
if (!acquirePrinterJobAndPageFormat(showDlg)) {
return;
}
getPrinterJob().setPrintable(mapView, getPageFormat());
if (!showDlg || printDialog()) {
if (mapView instanceof MapView)
((MapView) mapView).preparePrinting();
try {
final PrinterJob printerJob = getPrinterJob();
if (mapView instanceof Component) {
final String name = ((Component) mapView).getName();
if (name != null)
printerJob.setJobName(name);
}
printerJob.print();
} catch (PrinterException ex) {
LogUtils.warn(ex);
} finally {
if (mapView instanceof MapView)
((MapView) mapView).endPrinting();
}
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class Preview method paint.
@Override
public void paint(final Graphics g) {
try {
final Graphics2D g2d = (Graphics2D) g;
final PageFormat format = getPageFormat();
paintPaper(g, format);
if (previewPageImage == null) {
previewPageImage = (BufferedImage) createImage(getPageWidth(format) - 1, getPageHeight(format) - 1);
imageGraphics = previewPageImage.createGraphics();
imageGraphics.scale(zoom, zoom);
if (view instanceof MapView)
((MapView) view).preparePrinting();
while (Printable.NO_SUCH_PAGE == view.print(imageGraphics, format, index) && index > 0) {
index--;
}
if (view instanceof MapView)
((MapView) view).endPrinting();
}
g2d.drawImage(previewPageImage, 0, 0, this);
} catch (final PrinterException e) {
LogUtils.severe(e);
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class DefaultMouseWheelListener method mouseWheelMoved.
/*
* (non-Javadoc)
* @see
* freeplane.modes.ModeController.MouseWheelEventHandler#handleMouseWheelEvent
* (java.awt.event.MouseWheelEvent)
*/
public void mouseWheelMoved(final MouseWheelEvent e) {
final MapView mapView = (MapView) e.getSource();
final ModeController mController = mapView.getModeController();
if (mController.isBlocked()) {
return;
}
final Set<IMouseWheelEventHandler> registeredMouseWheelEventHandler = mController.getUserInputListenerFactory().getMouseWheelEventHandlers();
for (final IMouseWheelEventHandler handler : registeredMouseWheelEventHandler) {
final boolean result = handler.handleMouseWheelEvent(e);
if (result) {
return;
}
}
if ((e.getModifiers() & DefaultMouseWheelListener.ZOOM_MASK) != 0) {
float newZoomFactor = 1f + Math.abs((float) e.getWheelRotation()) / 10f;
if (e.getWheelRotation() < 0) {
newZoomFactor = 1 / newZoomFactor;
}
final float oldZoom = ((MapView) e.getComponent()).getZoom();
float newZoom = oldZoom / newZoomFactor;
newZoom = (float) Math.rint(newZoom * 1000f) / 1000f;
newZoom = Math.max(1f / 32f, newZoom);
newZoom = Math.min(32f, newZoom);
if (newZoom != oldZoom) {
Controller.getCurrentController().getMapViewManager().setZoom(newZoom);
}
} else if ((e.getModifiers() & DefaultMouseWheelListener.HORIZONTAL_SCROLL_MASK) != 0) {
((MapView) e.getComponent()).scrollBy(DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation(), 0);
} else {
((MapView) e.getComponent()).scrollBy(0, DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation());
}
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class DefaultNodeMouseMotionListener method mousePressed.
public void mousePressed(final MouseEvent e) {
final MapView mapView = MapView.getMapView(e.getComponent());
mapView.select();
doubleClickTimer.cancel();
showPopupMenu(e);
}
use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.
the class UserInputListenerFactory method updateMapList.
private void updateMapList(final String mapsMenuPosition) {
if (!getMenuBuilder(MenuBuilder.class).contains(mapsMenuPosition))
return;
getMenuBuilder(MenuBuilder.class).removeChildElements(mapsMenuPosition);
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final List<? extends Component> mapViewVector = mapViewManager.getMapViewVector();
if (mapViewVector == null) {
return;
}
final ButtonGroup group = new ButtonGroup();
int i = 0;
for (final Component mapView : mapViewVector) {
final String displayName = mapView.getName();
final JRadioButtonMenuItem newItem = new JRadioButtonMenuItem(displayName);
newItem.setSelected(false);
group.add(newItem);
newItem.addActionListener(mapsMenuActionListener);
if (displayName.length() > 0) {
newItem.setMnemonic(displayName.charAt(0));
}
final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
if (currentMapView != null) {
if (mapView == currentMapView) {
newItem.setSelected(true);
}
}
getMenuBuilder(MenuBuilder.class).addMenuItem(mapsMenuPosition, newItem, mapsMenuPosition + '-' + i++, UIBuilder.AS_CHILD);
}
}
Aggregations