use of org.freeplane.features.nodestyle.NodeStyleModel.Shape in project freeplane by freeplane.
the class MNodeStyleController method setShapeConfiguration.
public void setShapeConfiguration(final NodeModel node, final ShapeConfigurationModel shape) {
final ModeController modeController = Controller.getCurrentModeController();
final ShapeConfigurationModel oldShape = NodeStyleModel.getShapeConfiguration(node);
final IActor actor = new IActor() {
public void act() {
NodeStyleModel.setShapeConfiguration(node, shape);
modeController.getMapController().nodeChanged(node);
childShapeRefresh(node);
}
public String getDescription() {
return "setShape";
}
private void childShapeRefresh(final NodeModel node) {
for (final NodeModel child : modeController.getMapController().childrenUnfolded(node)) {
if (child.getViewers().isEmpty())
continue;
final Shape childShape = NodeStyleModel.getShape(child);
if (childShape == null || NodeStyleModel.Shape.as_parent.equals(childShape)) {
modeController.getMapController().nodeRefresh(child);
childShapeRefresh(child);
}
}
}
public void undo() {
NodeStyleModel.setShapeConfiguration(node, oldShape);
modeController.getMapController().nodeChanged(node);
childShapeRefresh(node);
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.nodestyle.NodeStyleModel.Shape in project freeplane by freeplane.
the class NodeView method setFolded.
private void setFolded(boolean folded, boolean force) {
boolean wasFolded = isFolded;
this.isFolded = folded;
if (wasFolded != isFolded || force) {
treeStructureChanged();
getMap().selectIfSelectionIsEmpty(this);
Shape shape = NodeStyleController.getController(getMap().getModeController()).getShape(model);
if (shape.equals(NodeStyleModel.Shape.combined))
update();
}
}
use of org.freeplane.features.nodestyle.NodeStyleModel.Shape in project freeplane by freeplane.
the class NodeStyleBuilder method writeAttributes.
private void writeAttributes(final ITreeWriter writer, final NodeModel node, final NodeStyleModel style, final boolean forceFormatting) {
final Color color = forceFormatting ? nsc.getColor(node) : style.getColor();
if (color != null) {
ColorUtils.addColorAttributes(writer, "COLOR", "ALPHA", color);
}
final Color backgroundColor = forceFormatting ? nsc.getBackgroundColor(node) : style.getBackgroundColor();
if (backgroundColor != null) {
ColorUtils.addColorAttributes(writer, "BACKGROUND_COLOR", "BACKGROUND_ALPHA", backgroundColor);
}
final ShapeConfigurationModel shapeConfiguration = forceFormatting ? nsc.getShapeConfiguration(node) : style.getShapeConfiguration();
final Shape shape = shapeConfiguration.getShape();
if (shape != null) {
writer.addAttribute("STYLE", shape.toString());
}
final Quantity<LengthUnits> shapeHorizontalMargin = shapeConfiguration.getHorizontalMargin();
if (!shapeHorizontalMargin.equals(ShapeConfigurationModel.DEFAULT_MARGIN)) {
BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("SHAPE_HORIZONTAL_MARGIN", shapeHorizontalMargin);
}
final Quantity<LengthUnits> shapeVerticalMargin = shapeConfiguration.getVerticalMargin();
if (!shapeVerticalMargin.equals(ShapeConfigurationModel.DEFAULT_MARGIN)) {
BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("SHAPE_VERTICAL_MARGIN", shapeVerticalMargin);
}
final boolean uniformShape = shapeConfiguration.isUniform();
if (uniformShape) {
writer.addAttribute("UNIFORM_SHAPE", "true");
}
final Boolean numbered = forceFormatting ? Boolean.valueOf(nsc.getNodeNumbering(node)) : style.getNodeNumbering();
if (numbered != null) {
writer.addAttribute("NUMBERED", Boolean.toString(numbered));
}
final String format = forceFormatting ? nsc.getNodeFormat(node) : style.getNodeFormat();
if (format != null) {
writer.addAttribute("FORMAT", format);
}
final HorizontalTextAlignment textAlignment = forceFormatting ? nsc.getHorizontalTextAlignment(node) : style.getHorizontalTextAlignment();
if (textAlignment != null) {
writer.addAttribute("TEXT_ALIGN", textAlignment.toString());
}
}
Aggregations