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() {
@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.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();
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);
detailHorizontalAlignment = style.getHorizontalTextAlignment(detailStyleNode).swingConstant;
final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
noteFont = UITools.scale(style.getFont(noteStyleNode));
noteBackground = style.getBackgroundColor(noteStyleNode);
noteForeground = style.getColor(noteStyleNode);
noteHorizontalAlignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
}
use of org.freeplane.features.nodestyle.NodeStyleController 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.nodestyle.NodeStyleController in project freeplane by freeplane.
the class MainView method updateBorder.
public void updateBorder(NodeView nodeView) {
final NodeStyleController controller = NodeStyleController.getController(nodeView.getMap().getModeController());
final NodeModel node = nodeView.getModel();
final Boolean borderWidthMatchesEdgeWidth = controller.getBorderWidthMatchesEdgeWidth(node);
if (borderWidthMatchesEdgeWidth)
unzoomedBorderWidth = getUnzoomedEdgeWidth();
else
unzoomedBorderWidth = (float) controller.getBorderWidth(node).toBaseUnits();
final Boolean borderDashMatchesEdgeDash = controller.getBorderDashMatchesEdgeDash(node);
if (borderDashMatchesEdgeDash)
dash = nodeView.getEdgeDash();
else
dash = controller.getBorderDash(node);
borderColorMatchesEdgeColor = controller.getBorderColorMatchesEdgeColor(node);
if (borderColorMatchesEdgeColor)
borderColor = null;
else
borderColor = controller.getBorderColor(node);
}
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).toBaseUnitsRounded();
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