@Override void setStyleOnExternalChange(NodeModel node) { final NodeSizeModel nodeSizeModel = NodeSizeModel.getModel(node); final NodeStyleController styleController = NodeStyleController.getController(); final Quantity<LengthUnits> width = nodeSizeModel != null ? nodeSizeModel.getMaxNodeWidth() : null; final Quantity<LengthUnits> viewWidth = styleController.getMaxWidth(node); mSetMaxNodeWidth.setValue(width != null); mMaxNodeWidth.setQuantifiedValue(viewWidth); } }
@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; }
private void writeAttributes(final ITreeWriter writer, final NodeModel node, final NodeSizeModel size, final boolean forceFormatting) { final Quantity<LengthUnits> maxTextWidth = forceFormatting ? nsc.getMaxWidth(node) : size.getMaxNodeWidth(); if (maxTextWidth != null) { BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("MAX_WIDTH", maxTextWidth); } final Quantity<LengthUnits> minTextWidth = forceFormatting ? nsc.getMinWidth(node) : size.getMinNodeWidth(); if (minTextWidth != null) { BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("MIN_WIDTH", minTextWidth); } }
final ModeController modeController = map.getModeController(); final NodeStyleController nsc = NodeStyleController.getController(modeController); final double maxNodeWidth = nsc.getMaxWidth(node.getModel()).toBaseUnits(); setMaximumWidth(Integer.MAX_VALUE); widthMustBeRestricted = getPreferredSize().width > map.getZoomed(maxNodeWidth);
.withBackground(view.getNodeView().getTextBackground()) .withAlignment(view.getHorizontalAlignment()) .withMaxWidthAsPt(zoom, style.getMaxWidth(node))); final Object data = node.getUserObject(); String text;
@Override public Dimension getPreferredScrollableViewportSize() { if (!isValid()) { validate(); } final Dimension dimension = super.getPreferredSize(); NodeView nodeView = getNodeViewAncestor(); if(nodeView != null){ final MapView map = nodeView.getMap(); final ModeController modeController = map.getModeController(); final NodeStyleController nsc = NodeStyleController.getController(modeController); dimension.width = Math.min(map.getZoomed(nsc.getMaxWidth(nodeView.getModel()).toBaseUnits()), dimension.width); dimension.height = Math.min(map.getZoomed(AttributeTable.MAX_HEIGTH) - getTableHeaderHeight(), dimension.height); } else{ // dimension.width = Math.min(MAX_WIDTH, dimension.width); // dimension.height = Math.min(MAX_HEIGTH, dimension.height); } return dimension; }
private String getTooltip(final ModeController modeController, NodeModel node, MainView view) { final DetailTextModel detailText = DetailTextModel.getDetailText(node); if (detailText == null || !(detailText.isHidden() || ShortenedTextModel.isShortened(node))) { return null; } final NodeStyleController style = modeController.getExtension(NodeStyleController.class); final MapStyleModel model = MapStyleModel.getExtension(node.getMap()); final NodeModel detailStyleNode = model.getStyleNodeSafe(MapStyleModel.DETAILS_STYLE); Font detailFont = style.getFont(detailStyleNode); Color detailBackground = style.getBackgroundColor(detailStyleNode); Color detailForeground = style.getColor(detailStyleNode); final int alignment = style.getHorizontalTextAlignment(detailStyleNode).swingConstant; float zoom = view.getNodeView().getMap().getZoom(); final StringBuilder htmlBodyStyle = new StringBuilder("<body><div style=\"") .append(new CssRuleBuilder() .withHTMLFont(detailFont) .withColor(detailForeground) .withBackground(detailBackground) .withAlignment(alignment) .withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(detailStyleNode), style.getMaxWidth(node))) .append("\">"); String noteText = detailText.getHtml(); final String tooltipText = noteText.replaceFirst("<body>", htmlBodyStyle.toString()) .replaceFirst("</body>", "</div></body>"); return tooltipText; } });
protected String getNoteCSSStyle(ModeController modeController, NodeModel node, float zoom, boolean asHtmlFragment) { final StringBuilder rule = new StringBuilder(); // set default font for notes: final NodeStyleController style = (NodeStyleController) Controller.getCurrentModeController().getExtension( NodeStyleController.class); MapModel map = modeController.getController().getMap(); if(map != null){ final MapStyleModel model = MapStyleModel.getExtension(map); final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE); final Font noteFont = style.getFont(noteStyleNode); Color noteBackground = style.getBackgroundColor(noteStyleNode); Color noteForeground = style.getColor(noteStyleNode); final int alignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant; final CssRuleBuilder cssRuleBuilder = new CssRuleBuilder(); if(asHtmlFragment) cssRuleBuilder.withHTMLFont(noteFont); else cssRuleBuilder.withCSSFont(noteFont); cssRuleBuilder.withColor(noteForeground) .withBackground(noteBackground) .withAlignment(alignment); if(asHtmlFragment) cssRuleBuilder.withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(noteStyleNode), style.getMaxWidth(node)); rule.append(cssRuleBuilder); } return rule.toString(); }
mapView.validate(); final NodeStyleController nsc = NodeStyleController.getController(modeController); maxWidth = Math.max(mapView.getZoomed(nsc.getMaxWidth(node).toBaseUnitsRounded()), parent.getWidth()); final Icon icon = parent.getIcon(); if(icon != null){
nodeColumnWidth = map.getZoomed(nodeStyleController.getMaxWidth(defaultStyleNode).toBaseUnitsRounded() + LocationModel.DEFAULT_HGAP_PX);
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);