|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2025 Obeo. |
| 3 | + * This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License v2.0 |
| 5 | + * which accompanies this distribution, and is available at |
| 6 | + * https://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * Obeo - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | +package org.eclipse.syson.application.nodes; |
| 14 | + |
| 15 | +import java.text.MessageFormat; |
| 16 | +import java.util.Objects; |
| 17 | + |
| 18 | +import org.eclipse.sirius.components.annotations.Immutable; |
| 19 | +import org.eclipse.sirius.components.diagrams.INodeStyle; |
| 20 | +import org.eclipse.sirius.components.diagrams.LineStyle; |
| 21 | + |
| 22 | +/** |
| 23 | + * The SysML view frame node style. |
| 24 | + * |
| 25 | + * @author frouene |
| 26 | + */ |
| 27 | +@Immutable |
| 28 | +public final class SysMLViewFrameNodeStyle implements INodeStyle { |
| 29 | + |
| 30 | + private String background; |
| 31 | + |
| 32 | + private String borderColor; |
| 33 | + |
| 34 | + private int borderSize; |
| 35 | + |
| 36 | + private LineStyle borderStyle; |
| 37 | + |
| 38 | + private int borderRadius; |
| 39 | + |
| 40 | + private SysMLViewFrameNodeStyle() { |
| 41 | + // Prevent instantiation |
| 42 | + } |
| 43 | + |
| 44 | + public static Builder newSysMLViewFrameNodeStyle() { |
| 45 | + return new Builder(); |
| 46 | + } |
| 47 | + |
| 48 | + public String getBackground() { |
| 49 | + return this.background; |
| 50 | + } |
| 51 | + |
| 52 | + public String getBorderColor() { |
| 53 | + return this.borderColor; |
| 54 | + } |
| 55 | + |
| 56 | + public int getBorderSize() { |
| 57 | + return this.borderSize; |
| 58 | + } |
| 59 | + |
| 60 | + public LineStyle getBorderStyle() { |
| 61 | + return this.borderStyle; |
| 62 | + } |
| 63 | + |
| 64 | + public int getBorderRadius() { |
| 65 | + return this.borderRadius; |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public String toString() { |
| 70 | + String pattern = "{0} '{'color: {1}, border: '{' background: {2}, size: {3}, style: {4} '}''}'"; |
| 71 | + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.background, this.borderColor, this.borderSize, this.borderStyle); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * The builder used to create the view frame node style. |
| 76 | + * |
| 77 | + * @author frouene |
| 78 | + */ |
| 79 | + @SuppressWarnings("checkstyle:HiddenField") |
| 80 | + public static final class Builder { |
| 81 | + |
| 82 | + private String background; |
| 83 | + |
| 84 | + private String borderColor; |
| 85 | + |
| 86 | + private int borderSize; |
| 87 | + |
| 88 | + private LineStyle borderStyle; |
| 89 | + |
| 90 | + private int borderRadius; |
| 91 | + |
| 92 | + private Builder() { |
| 93 | + // Prevent instantiation |
| 94 | + } |
| 95 | + |
| 96 | + public Builder background(String background) { |
| 97 | + this.background = Objects.requireNonNull(background); |
| 98 | + return this; |
| 99 | + } |
| 100 | + |
| 101 | + public Builder borderColor(String borderColor) { |
| 102 | + this.borderColor = Objects.requireNonNull(borderColor); |
| 103 | + return this; |
| 104 | + } |
| 105 | + |
| 106 | + public Builder borderSize(int borderSize) { |
| 107 | + this.borderSize = borderSize; |
| 108 | + return this; |
| 109 | + } |
| 110 | + |
| 111 | + public Builder borderStyle(LineStyle borderStyle) { |
| 112 | + this.borderStyle = Objects.requireNonNull(borderStyle); |
| 113 | + return this; |
| 114 | + } |
| 115 | + |
| 116 | + public Builder borderRadius(int borderRadius) { |
| 117 | + this.borderRadius = borderRadius; |
| 118 | + return this; |
| 119 | + } |
| 120 | + |
| 121 | + public SysMLViewFrameNodeStyle build() { |
| 122 | + SysMLViewFrameNodeStyle nodeStyleDescription = new SysMLViewFrameNodeStyle(); |
| 123 | + nodeStyleDescription.background = Objects.requireNonNull(this.background); |
| 124 | + nodeStyleDescription.borderColor = Objects.requireNonNull(this.borderColor); |
| 125 | + nodeStyleDescription.borderSize = this.borderSize; |
| 126 | + nodeStyleDescription.borderStyle = Objects.requireNonNull(this.borderStyle); |
| 127 | + nodeStyleDescription.borderRadius = this.borderRadius; |
| 128 | + return nodeStyleDescription; |
| 129 | + } |
| 130 | + } |
| 131 | +} |
0 commit comments