use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class TextController method registerNodeTextTooltip.
private void registerNodeTextTooltip() {
modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {
@Override
public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
return getTooltip(modeController, node, (MainView) view);
}
private String getTooltip(final ModeController modeController, NodeModel node, MainView view) {
if (!ShortenedTextModel.isShortened(node)) {
return null;
}
final NodeStyleController style = modeController.getExtension(NodeStyleController.class);
final Font font = style.getFont(node);
float zoom = view.getNodeView().getMap().getZoom();
final StringBuilder htmlBodyStyle = new StringBuilder("<body><div style=\"").append(new CssRuleBuilder().withHTMLFont(font).withColor(view.getForeground()).withBackground(view.getNodeView().getTextBackground()).withAlignment(view.getHorizontalAlignment()).withMaxWidthAsPt(zoom, style.getMaxWidth(node)));
final Object data = node.getUserObject();
String text;
try {
text = getTransformedText(data, node, data);
if (text.equals(getShortText(text)))
return null;
} catch (Exception e) {
text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
htmlBodyStyle.append("color:red;");
}
htmlBodyStyle.append("\">");
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
final String tooltipText = text.replaceFirst("<body>", htmlBodyStyle.toString()).replaceFirst("</body>", "</div></body>");
return tooltipText;
}
});
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MapViewController method setMapTitles.
public void setMapTitles() {
final ModeController modeController = Controller.getCurrentModeController();
if (modeController == null) {
controller.getViewController().setTitle("");
return;
}
final Object[] messageArguments = { TextUtils.getText(("mode_" + modeController.getModeName())) };
final MessageFormat formatter = new MessageFormat(TextUtils.getText("mode_title"));
String frameTitle = formatter.format(messageArguments);
String viewName = "";
final MapModel model = getModel();
if (model != null) {
viewName = getMapViewComponent().getName();
frameTitle = viewName + ((model.isSaved() || model.isReadOnly()) ? "" : "*") + " - " + frameTitle + (model.isReadOnly() ? " (" + TextUtils.getText("read_only") + ")" : "");
final File file = model.getFile();
if (file != null) {
frameTitle += " " + file.getAbsolutePath();
}
}
controller.getViewController().setTitle(frameTitle);
modeController.getUserInputListenerFactory().updateMapList();
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeView method update.
public void update() {
invalidate();
updateShape();
updateEdge();
if (!isContentVisible()) {
mainView.setVisible(false);
return;
}
mainView.setVisible(true);
mainView.updateTextColor(this);
mainView.updateFont(this);
mainView.updateHorizontalTextAlignment(this);
mainView.updateBorder(this);
MapView map = getMap();
final ModeController modeController = map.getModeController();
final NodeStyleController nsc = NodeStyleController.getController(modeController);
final int minNodeWidth = map.getZoomed(nsc.getMinWidth(getModel()).toBaseUnits());
final int maxNodeWidth = Math.max(map.getLayoutSpecificMaxNodeWidth(), map.getZoomed(nsc.getMaxWidth(getModel()).toBaseUnits()));
mainView.setMinimumWidth(minNodeWidth);
mainView.setMaximumWidth(maxNodeWidth);
createAttributeView();
if (attributeView != null) {
attributeView.update();
}
final boolean textShortened = isShortened();
if (!textShortened) {
final NodeViewFactory nodeViewFactory = NodeViewFactory.getInstance();
nodeViewFactory.updateDetails(this, minNodeWidth, maxNodeWidth);
nodeViewFactory.updateNoteViewer(this, minNodeWidth, maxNodeWidth);
if (contentPane != null) {
final int componentCount = contentPane.getComponentCount();
for (int i = 1; i < componentCount; i++) {
final Component component = contentPane.getComponent(i);
if (component instanceof JComponent) {
((JComponent) component).revalidate();
}
}
}
}
updateShortener(getModel(), textShortened);
mainView.updateIcons(this);
mainView.updateText(getModel());
updateCloud();
modelBackgroundColor = NodeStyleController.getController(getMap().getModeController()).getBackgroundColor(model);
revalidate();
repaint();
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeView method isShortened.
public boolean isShortened() {
final ModeController modeController = getMap().getModeController();
final TextController textController = TextController.getController(modeController);
final boolean textShortened = textController.isMinimized(getModel());
return textShortened;
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeView method setMainView.
void setMainView(final MainView newMainView) {
if (contentPane != null) {
assert (contentPane.getParent() == this);
if (mainView != null)
removeContent(MAIN_VIEWER_POSITION);
addContent(newMainView, MAIN_VIEWER_POSITION);
assert (contentPane.getParent() == this);
} else if (mainView != null) {
final Container c = mainView.getParent();
int i;
for (i = c.getComponentCount() - 1; i >= 0 && mainView != c.getComponent(i); i--) {
;
}
c.remove(i);
c.add(newMainView, i);
} else {
add(newMainView);
}
mainView = newMainView;
ModeController modeController = getMap().getModeController();
if (modeController.canEdit(getModel())) {
final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
mainView.addMouseListener(userInputListenerFactory.getNodeMouseMotionListener());
mainView.addMouseMotionListener(userInputListenerFactory.getNodeMouseMotionListener());
mainView.addMouseWheelListener(userInputListenerFactory.getNodeMouseWheelListener());
mainView.addKeyListener(userInputListenerFactory.getNodeKeyListener());
addDragListener(userInputListenerFactory.getNodeDragListener());
addDropListener(userInputListenerFactory.getNodeDropTargetListener());
}
}
Aggregations