use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.
the class TextController method registerNodeTextTooltip.
private void registerNodeTextTooltip() {
modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {
public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
if (!ShortenedTextModel.isShortened(node)) {
return null;
}
final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
final Font font = style.getFont(node);
final StringBuilder rule = new StringBuilder();
rule.append("font-family: " + font.getFamily() + ";");
rule.append("font-size: " + font.getSize() + "pt;");
rule.append("margin-top:0;");
if (font.isItalic()) {
rule.append("font-style: italic; ");
}
if (font.isBold()) {
rule.append("font-weight: bold; ");
}
final Color nodeTextColor = view.getForeground();
rule.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
final Object data = node.getUserObject();
String text;
try {
text = getTransformedText(data, node, data);
} catch (Exception e) {
text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
rule.append("color:red;");
}
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
final String tooltipText = text.replaceFirst("<body>", "<body><div style=\"" + rule + "\">").replaceFirst("</body>", "</div></body>");
return tooltipText;
}
});
}
use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.
the class FModeControllerFactory method createModeController.
public static FModeController createModeController() {
final Controller controller = Controller.getCurrentController();
modeController = new FModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new FMapController(modeController);
UrlManager.install(new UrlManager());
MapIO.install(modeController);
IconController.install(new IconController(modeController));
NodeStyleController.install(new NodeStyleController(modeController));
EdgeController.install(new EdgeController(modeController));
TextController.install(new TextController(modeController));
LinkController.install(new LinkController());
CloudController.install(new CloudController(modeController));
ClipboardController.install(new ClipboardController());
LocationController.install(new LocationController());
LogicalStyleController.install(new LogicalStyleController(modeController));
MapStyle.install(true);
NodeStyleController.getController().addShapeGetter(new Integer(0), new IPropertyHandler<String, NodeModel>() {
public String getProperty(final NodeModel node, final String currentValue) {
return "fork";
}
});
modeController.addAction(new CenterAction());
modeController.addAction(new OpenPathAction());
userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, FilterController.getCurrentFilterController().getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
NodeHistory.install(modeController);
return modeController;
}
use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.
the class MapView method updateContentStyle.
private void updateContentStyle() {
final NodeStyleController style = Controller.getCurrentModeController().getExtension(NodeStyleController.class);
MapModel map = getModel();
noteFont = UITools.scale(style.getDefaultFont(map, MapStyleModel.NOTE_STYLE));
final MapStyleModel model = MapStyleModel.getExtension(map);
final NodeModel detailStyleNode = model.getStyleNodeSafe(MapStyleModel.DETAILS_STYLE);
detailFont = UITools.scale(style.getFont(detailStyleNode));
detailBackground = style.getBackgroundColor(detailStyleNode);
detailForeground = style.getColor(detailStyleNode);
}
use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.
the class ZoomableLabel method updateTextUnsafe.
private void updateTextUnsafe(String nodeText) throws Exception {
final NodeView node = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, this);
final MapView map = node.getMap();
if (map == null || nodeText == null) {
return;
}
final boolean isHtml = nodeText.startsWith("<html>");
boolean widthMustBeRestricted = false;
boolean isLong = false;
final ModeController modeController = map.getModeController();
final NodeStyleController nsc = NodeStyleController.getController(modeController);
final int maxNodeWidth = nsc.getMaxWidth(node.getModel());
if (!isHtml) {
final String[] lines = nodeText.split("\n");
for (int line = 0; line < lines.length; line++) {
setText(lines[line]);
widthMustBeRestricted = getPreferredSize().width > map.getZoomed(maxNodeWidth);
if (widthMustBeRestricted) {
break;
}
}
isLong = widthMustBeRestricted || lines.length > 1;
}
if (isHtml) {
if (nodeText.indexOf("<img") >= 0 && nodeText.indexOf("<base ") < 0) {
nodeText = "<html><base href=\"" + map.getModel().getURL() + "\">" + nodeText.substring(6);
}
final String htmlLongNodeHead = ResourceController.getResourceController().getProperty("html_long_node_head");
if (htmlLongNodeHead != null && !htmlLongNodeHead.equals("")) {
if (nodeText.matches("(?ims).*<head>.*")) {
nodeText = nodeText.replaceFirst("(?ims).*<head>.*", "<head>" + htmlLongNodeHead);
} else {
nodeText = nodeText.replaceFirst("(?ims)<html>", "<html><head>" + htmlLongNodeHead + "</head>");
}
}
setText(nodeText);
} else if (nodeText.startsWith("<table>")) {
final String[] lines = nodeText.split("\n");
lines[0] = lines[0].substring(7);
final int startingLine = lines[0].matches("\\s*") ? 1 : 0;
String text = "<html><table border=1 style=\"border-color: white\">";
for (int line = startingLine; line < lines.length; line++) {
text += "<tr><td style=\"border-color: white;\">" + HtmlUtils.toXMLEscapedText(lines[line]).replaceAll("\t", "<td style=\"border-color: white\">");
}
setText(text);
} else if (isLong) {
String text = HtmlUtils.plainToHTML(nodeText);
setText(text);
} else {
setText(nodeText);
}
}
use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.
the class LatexRenderer method getIcon.
@Override
public Icon getIcon(TextController textController, Object content, NodeModel node, Object transformedExtension) {
if (transformedExtension == node.getUserObject()) {
String string = content.toString();
String nodeFormat = textController.getNodeFormat(node);
if (PatternFormat.IDENTITY_PATTERN.equals(nodeFormat))
return null;
final String latext = getLatexNode(string, nodeFormat, TargetMode.FOR_ICON);
if (latext == null)
return null;
final NodeStyleController ncs = NodeStyleController.getController(textController.getModeController());
final int maxWidth = ncs.getMaxWidth(node);
TeXText teXt = new TeXText(latext);
int fontSize = Math.round(ncs.getFontSize(node) * UITools.FONT_SCALE_FACTOR);
TeXIcon icon = teXt.createTeXIcon(TeXConstants.STYLE_DISPLAY, fontSize, TeXConstants.ALIGN_LEFT, maxWidth);
return icon;
}
return null;
}
Aggregations