use of org.freeplane.features.attribute.FontSizeExtension in project freeplane by freeplane.
the class MapStyleModel method createStyleMap.
void createStyleMap(final MapModel parentMap, MapStyleModel mapStyleModel, final String styleMapStr) {
final ModeController modeController = Controller.getCurrentModeController();
MapModel styleMap = new StyleMapModel(parentMap.getIconRegistry(), AttributeRegistry.getRegistry(parentMap));
styleMap.createNewRoot();
final MapReader mapReader = modeController.getMapController().getMapReader();
final Reader styleReader = new StringReader(styleMapStr);
NodeModel root;
try {
Map<Object, Object> hints = new HashMap<Object, Object>();
hints.put(Hint.MODE, Mode.FILE);
hints.put(NodeBuilder.FOLDING_LOADED, Boolean.TRUE);
root = mapReader.createNodeTreeFromXml(styleMap, styleReader, hints);
NodeStyleModel.setShapeConfiguration(root, ShapeConfigurationModel.NULL_SHAPE.withShape(NodeStyleModel.Shape.oval).withUniform(true));
NodeStyleModel.createNodeStyleModel(root).setFontSize(24);
styleMap.setRoot(root);
final Quantity<LengthUnits> styleBlockGap = ResourceController.getResourceController().getLengthQuantityProperty("style_block_gap");
LocationModel.createLocationModel(root).setVGap(styleBlockGap);
insertStyleMap(parentMap, styleMap);
NodeModel predefinedStyleParentNode = createStyleGroupNode(styleMap, STYLES_PREDEFINED);
createStyleGroupNode(styleMap, STYLES_USER_DEFINED);
createStyleGroupNode(styleMap, STYLES_AUTOMATIC_LAYOUT);
if (styleNodes.get(DEFAULT_STYLE) == null) {
final NodeModel newNode = new NodeModel(DEFAULT_STYLE, styleMap);
predefinedStyleParentNode.insert(newNode, 0);
addStyleNode(newNode);
}
NodeModel defaultStyleModel = styleNodes.get(DEFAULT_STYLE);
if (maxNodeWidth != null && null == NodeSizeModel.getMaxNodeWidth(defaultStyleModel))
NodeSizeModel.setMaxNodeWidth(defaultStyleModel, maxNodeWidth);
if (minNodeWidth != null && null == NodeSizeModel.getMinNodeWidth(defaultStyleModel))
NodeSizeModel.setNodeMinWidth(defaultStyleModel, minNodeWidth);
if (styleNodes.get(DETAILS_STYLE) == null) {
final NodeModel newNode = new NodeModel(DETAILS_STYLE, styleMap);
predefinedStyleParentNode.insert(newNode, 1);
addStyleNode(newNode);
}
if (styleNodes.get(ATTRIBUTE_STYLE) == null) {
final NodeModel newNode = new NodeModel(ATTRIBUTE_STYLE, styleMap);
final int defaultFontSize = 9;
NodeStyleModel.createNodeStyleModel(newNode).setFontSize(defaultFontSize);
predefinedStyleParentNode.insert(newNode, 2);
addStyleNode(newNode);
}
FontSizeExtension fontSizeExtension = parentMap.getExtension(FontSizeExtension.class);
if (fontSizeExtension != null) {
NodeStyleModel.createNodeStyleModel(styleNodes.get(ATTRIBUTE_STYLE)).setFontSize(fontSizeExtension.fontSize);
}
if (styleNodes.get(NOTE_STYLE) == null) {
final NodeModel newNode = new NodeModel(NOTE_STYLE, styleMap);
NodeStyleModel.createNodeStyleModel(newNode).setBackgroundColor(Color.WHITE);
predefinedStyleParentNode.insert(newNode, 3);
addStyleNode(newNode);
}
if (styleNodes.get(FLOATING_STYLE) == null) {
final NodeModel newNode = new NodeModel(FLOATING_STYLE, styleMap);
EdgeModel.createEdgeModel(newNode).setStyle(EdgeStyle.EDGESTYLE_HIDDEN);
CloudModel.createModel(newNode).setShape(CloudModel.Shape.ROUND_RECT);
predefinedStyleParentNode.insert(newNode, 4);
addStyleNode(newNode);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations