use of org.freeplane.view.swing.map.NodeView 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.NodeView in project freeplane by freeplane.
the class ViewerController method createViewer.
void createViewer(final ExternalResource model, final NodeView view) {
final JComponent viewer = createViewer(view.getMap().getModel(), model);
if (imagePopupMenu == null) {
imagePopupMenu = new ExternalImagePopupMenu();
}
viewer.setBorder(new MatteBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_COLOR));
final Set<NodeView> viewers = model.getViewers();
viewers.add(view);
viewer.setBounds(viewer.getX() - 5, viewer.getY() - 5, viewer.getWidth() + 15, viewer.getHeight() + 15);
view.addContent(viewer, VIEWER_POSITION);
if (view.getMap().getModeController().canEdit()) {
final DropTarget dropTarget = new DropTarget(viewer, DTL);
dropTarget.setActive(true);
}
if (view.isShortened())
viewer.setVisible(false);
else {
viewer.revalidate();
viewer.repaint();
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class ViewerController method add.
@Override
protected void add(final NodeModel node, final IExtension extension) {
final ExternalResource preview = (ExternalResource) extension;
for (NodeModel nodeClone : node.clones()) {
for (final INodeView iNodeView : nodeClone.getViewers()) {
final NodeView view = (NodeView) iNodeView;
createViewer(preview, view);
}
}
super.add(node, extension);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class ViewerController method onViewRemoved.
public void onViewRemoved(final Container container) {
final NodeView nodeView = (NodeView) container;
final ExternalResource previewUri = nodeView.getModel().getExtension(ExternalResource.class);
if (previewUri == null) {
return;
}
deleteViewer(previewUri, nodeView);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class ExternalImagePopupMenu method getRemove.
/**
* @return Returns the delete menu item.
*/
private JMenuItem getRemove() {
final ProgressUtilities progUtil = new ProgressUtilities();
if (remove == null) {
remove = new JMenuItem(TextUtils.getText("ExternalImage_popupMenu_Remove"));
remove.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final ExternalResource extRes = node.getExtension(ExternalResource.class);
if (progUtil.hasExternalResource(node) && !progUtil.hasExtendedProgressIcon(node)) {
viewer.remove(node, extRes);
NodeView nv = null;
final Collection<INodeView> invs = Controller.getCurrentController().getModeController().getMapController().getSelectedNode().getViewers();
for (final INodeView inv : invs) {
if (inv instanceof NodeView) {
nv = (NodeView) inv;
break;
}
}
viewer.deleteViewer(extRes, nv);
viewer.undoableDeactivateHook(node);
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.UNKNOWN_PROPERTY, null, null);
}
}
});
}
return remove;
}
Aggregations