Commit 43e6c743 authored by Nico Mack's avatar Nico Mack

Systematic addition of blinkOnOutOfRange property.

Initial commit of VariableHtmlBox corona.
parent 17119bca
......@@ -3,6 +3,7 @@ BELOW_ELEMENT=below
BLINK_ON_OUT_OF_RANGE_NODE=blinkOnOutOfRange
CAPPED_DISPLAY_NODE=cappedDisplay
ITEMS_VARIABLE_NODE=itemsVariable
HTML_TEMPLATE_NODE=htmlTemplate
LABEL_NODE=label
LOWER_BOUND_RADIUS_NODE=lowerBoundRadius
LOWER_BOUND_VARIABLE_NODE=lowerBoundVariable
......
......@@ -2,6 +2,7 @@ package lu.list.itis.dkd.tui.marker;
import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.system.VariableBased;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.marker.builder.BaseDisplayMarkerBuilder;
......@@ -11,20 +12,20 @@ import org.python.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
@SuppressWarnings("rawtypes")
public class DisplayMarker extends InfoMarker implements InputChangeListener {
public class DisplayMarker extends InfoMarker implements InputChangeListener, VariableBased {
private HashMap<String, NumericalVariable> variables;
private HashMap<String, Variable<?>> variables;
HashMap<String, ValueCorona> dispatcher;
// ***************************************************************************
......@@ -43,20 +44,8 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
public DisplayMarker(BaseDisplayMarkerBuilder<?> builder) {
super(builder);
if (builder.variables != null) {
this.setVariables(builder.variables);
}
this.dispatcher = new HashMap<String, ValueCorona>();
List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for (ValueCorona display : displays) {
Variable<?> variable = display.getVariable();
if (variable != null) {
dispatcher.put(variable.getName(), display);
}
}
// TODO Auto-generated constructor stub
this.variables = new HashMap<>();
this.dispatcher = new HashMap<>();
}
// ---------------------------------------------------------------------------
......@@ -71,47 +60,40 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
// ***************************************************************************
// ---------------------------------------------------------------------------
public void setVariables(Collection<Variable<?>> newVariables) {
Preconditions.checkArgument(variables == null, "Set of variables can't be null!"); //$NON-NLS-1$
this.variables = new HashMap<String, NumericalVariable>();
for (Variable<?> variable : newVariables) {
this.variables.put(variable.getName(), (NumericalVariable) variable);
}
List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for (ValueCorona display : displays) {
Variable<?> variable = display.getVariable();
if (variable != null) {
String variableName = variable.getName();
if (this.variables.containsKey(variableName)) {
display.setVariable(this.variables.get(variableName));
} else {
LOGGER.warn("Corona requires variable {} unkown to display widget!", variableName); //$NON-NLS-1$
}
}
}
}
// public void setVariables(Collection<Variable<?>> newVariables) {
// Preconditions.checkArgument(variables == null, "Set of variables can't be null!"); //$NON-NLS-1$
//
// this.variables = new HashMap<String, NumericalVariable>();
// for (Variable<?> variable : newVariables) {
// this.variables.put(variable.getName(), (NumericalVariable) variable);
// }
//
// List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
// for (ValueCorona display : displays) {
// Variable<?> variable = display.getVariable();
// if (variable != null) {
// String variableName = variable.getName();
// if (this.variables.containsKey(variableName)) {
// display.setVariable(this.variables.get(variableName));
// } else {
// LOGGER.warn("Corona requires variable {} unkown to display widget!", variableName); //$NON-NLS-1$
// }
// }
// }
// }
// ---------------------------------------------------------------------------
public Collection<Variable<?>> getVariables() {
Collection<Variable<?>> variables = new ArrayList<>();
List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for (ValueCorona display : displays) {
Variable<?> variable = display.getVariable();
if (variable != null) {
variables.add(variable);
}
}
return variables;
}
// ---------------------------------------------------------------------------
@Override
public void paint(Graphics2D canvas) {
super.paint(canvas);
// Collection<Variable<?>> variables = new ArrayList<>();
// List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
// for (ValueCorona display : displays) {
// Variable<?> variable = display.getVariable();
// if (variable != null) {
// variables.add(variable);
// }
// }
return variables.values();
}
// ---------------------------------------------------------------------------
......@@ -129,5 +111,35 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener {
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public List<Variable<?>> connectWithSystemVariables(Map<String, Variable<?>> systemVariables) {
List<Variable<?>> connected = new ArrayList<>();
Preconditions.checkArgument(systemVariables != null, "Set of variables can't be null!"); //$NON-NLS-1$
List<VariableBased> displays = this.getCoronas(VariableBased.class);
for (VariableBased display : displays) {
List<Variable<?>> newlyConnected = display.connectWithSystemVariables(systemVariables);
connected.addAll(newlyConnected);
if (display instanceof ValueCorona) {
for (Variable<?> variable : newlyConnected) {
this.dispatcher.put(variable.getName(), (ValueCorona) display);
}
}
}
for (Variable<?> variable : connected) {
this.variables.put(variable.getName(), variable);
variable.addListener(this);
}
return connected;
}
// ---------------------------------------------------------------------------
}
......@@ -32,6 +32,8 @@ public class CpsNamespace extends NLS {
public static String CAPPED_DISPLAY_NODE;
public static String HTML_TEMPLATE_NODE;
public static String ITEMS_VARIABLE_NODE;
public static String LABEL_NODE;
......
......@@ -108,6 +108,21 @@ public class Interpolator {
// ***************************************************************************
// ---------------------------------------------------------------------------
public static List<String> extractVariableIdentifiers(String template) {
Matcher variableMatcher;
List<String> identifiers = new ArrayList<>();
variableMatcher = VARIABLE_PATTERN.matcher(template);
while (variableMatcher.find()) {
identifiers.add(variableMatcher.group(1));
}
return identifiers;
}
// ---------------------------------------------------------------------------
public static List<Chunk<?>> decompose(String template, Map<String, Variable<?>> parameters) {
Matcher variableMatcher;
String format;
......
......@@ -40,6 +40,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
private double startAngle;
private double arcSpan;
private boolean relative;
private boolean blinkOnOutOfRange;
private double reference;
private int rampingTime;
......@@ -102,6 +103,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this.startAngle = builder.startAngle;
this.arcSpan = builder.arcSpan;
this.relative = builder.relative;
this.blinkOnOutOfRange = builder.blinkOnOutOfRange;
this.reference = builder.reference;
this.rampingTime = builder.rampingTime;
......@@ -139,6 +141,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this.startAngle = original.startAngle;
this.arcSpan = original.arcSpan;
this.relative = original.relative;
this.blinkOnOutOfRange = original.blinkOnOutOfRange;
this.reference = original.reference;
this.rampingTime = original.rampingTime;
......@@ -318,7 +321,7 @@ public class ArcRangeGraph extends ValueRangeCorona {
this.updateLeader();
if ((shownUpperValue == this.upperBoundVariable.getMaxValue()) || (relative && (shownLowerValue == this.lowerBoundVariable.getMinValue())))
if (blinkOnOutOfRange && ((shownUpperValue == this.upperBoundVariable.getMaxValue()) || (relative && (shownLowerValue == this.lowerBoundVariable.getMinValue()))))
this.startBlinking();
else
this.stopBlinking();
......
......@@ -46,13 +46,11 @@ public class ShapeGraph extends ValueCorona {
protected ColorPair strokeColour;
protected int strokeWidth;
protected Shape scaledShape;
protected boolean blinkOnOutOfRange;
protected Timeline blinkingTimeline;
protected Timeline balisticTimeline;
private double shownValue;
private float angle;
private float opacity;
private double scale;
private Stroke borderStroke;
// ---------------------------------------------------------------------------
......@@ -67,6 +65,7 @@ public class ShapeGraph extends ValueCorona {
super(builder);
this.lowerBound = builder.lowerBound;
this.upperBound = builder.upperBound;
this.blinkOnOutOfRange = builder.blinkOnOutOfRange;
this.fillColour = builder.fillColour;
this.strokeColour = builder.strokeColour;
this.strokeWidth = builder.strokeWidth;
......@@ -92,6 +91,7 @@ public class ShapeGraph extends ValueCorona {
this.lowerBound = original.lowerBound;
this.upperBound = original.upperBound;
this.blinkOnOutOfRange = original.blinkOnOutOfRange;
this.fillColour = original.fillColour;
this.strokeColour = original.strokeColour;
this.strokeWidth = original.strokeWidth;
......@@ -137,16 +137,14 @@ public class ShapeGraph extends ValueCorona {
shownValue = value;
if (variable != null) {
// double size = lowerBound + (upperBound - lowerBound) * (shownValue - this.variable.getMinValue())
// / (this.variable.getMaxValue() - this.variable.getMinValue());
double size = lowerBound + ((upperBound - lowerBound) * this.variable.getNormalizedValue());
if (size == upperBound)
if (blinkOnOutOfRange && (size == upperBound))
this.startBlinking();
else
this.stopBlinking();
scale = size / lowerBound;
double scale = size / lowerBound;
AffineTransform scaler = AffineTransform.getScaleInstance(scale, scale);
scaledShape = scaler.createTransformedShape(this.shape);
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. All rights reserved. If you wish
* to use this code for any purpose, please contact the author(s).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package lu.list.itis.dkd.tui.widget.corona;
import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.system.VariableBased;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.utility.interpolation.Chunk;
import lu.list.itis.dkd.tui.utility.interpolation.Interpolator;
import lu.list.itis.dkd.tui.widget.corona.builder.BaseVariableHtmlBoxBuilder;
import org.python.google.common.base.Strings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Extends the static HtmlBox corona by allowing variables inside the Html content.
*
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5.0
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChangeListener {
private String htmlTemplate;
private List<Chunk<?>> htmlChunks;
private List<String> identifiers;
private Map<String, Variable<?>> parameters;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param builder
*/
// ---------------------------------------------------------------------------
public VariableHtmlBox(BaseVariableHtmlBoxBuilder<?> builder) {
super(builder);
htmlTemplate = builder.htmlTemplate;
this.parameters = new HashMap<>();
if (!Strings.isNullOrEmpty(this.htmlTemplate)) {
identifiers = Interpolator.extractVariableIdentifiers(this.htmlTemplate);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public List<Variable<?>> connectWithSystemVariables(Map<String, Variable<?>> systemVariables) {
List<Variable<?>> connected = new ArrayList<>();
for (String identifier : identifiers) {
if ((systemVariables != null) && systemVariables.containsKey(identifier)) {
Variable<?> variable = systemVariables.get(identifier);
this.parameters.put(identifier, variable);
connected.add(variable);
variable.addListener(this);
}
}
if (!connected.isEmpty()) {
htmlChunks = Interpolator.decompose(this.htmlTemplate, this.parameters);
}
return connected;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public void inputChanged(InputEvent input) {
if (parameters.containsKey(input.getSource().getName())) {
this.htmlContent = Interpolator.render(htmlChunks);
this.setInformation(this.htmlContent);
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
......@@ -38,6 +38,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
public int arcSpan;
public boolean relative;
public boolean cappedDisplay;
public boolean blinkOnOutOfRange;
public double reference;
public int rampingTime;
......@@ -96,6 +97,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
arcSpan = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.ARC_SPAN_NODE, BootstrappingUtils.MANDATORY, null, context);
relative = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.RELATIVE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
cappedDisplay = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.CAPPED_DISPLAY_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
blinkOnOutOfRange = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.BLINK_ON_OUT_OF_RANGE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
reference = BootstrappingUtils.getContentAsDouble(rootElement, CpsNamespace.REFERENCE_NODE, BootstrappingUtils.OPTIONAL, 0d, context);
innerRadius = BootstrappingUtils.getContentAsDouble(rootElement, Externalization.INNER_RADIUS_NODE, BootstrappingUtils.MANDATORY, null, context);
......@@ -113,6 +115,7 @@ public class ArcGraphBuilder extends ValueCoronaBuilder<ArcGraphBuilder> {
faceColour = buildColorPair(rootElement.getChild(Externalization.FACE_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
bezelColour = buildColorPair(rootElement.getChild(Externalization.BEZEL_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
labelShape = ShapeBootstrapper.getShape(rootElement.getChild(Externalization.LABEL_SHAPE_NODE), context, callback);
title = BootstrappingUtils.getContentAsString(rootElement, Externalization.TITLE_NODE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING, context);
......
......@@ -37,6 +37,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
public int startAngle;
public int arcSpan;
public boolean relative;
public boolean blinkOnOutOfRange;
public double reference;
public int rampingTime;
......@@ -98,6 +99,7 @@ public abstract class BaseArcRangeGraphBuilder<B extends BaseArcRangeGraphBuilde
startAngle = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.START_ANGLE_NODE, BootstrappingUtils.MANDATORY, null, context);
arcSpan = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.ARC_SPAN_NODE, BootstrappingUtils.MANDATORY, null, context);
relative = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.RELATIVE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
blinkOnOutOfRange = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.BLINK_ON_OUT_OF_RANGE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
reference = BootstrappingUtils.getContentAsDouble(rootElement, CpsNamespace.REFERENCE_NODE, BootstrappingUtils.OPTIONAL, 0d, context);
innerRadius = BootstrappingUtils.getContentAsDouble(rootElement, Externalization.INNER_RADIUS_NODE, BootstrappingUtils.MANDATORY, null, context);
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.widget.corona.builder;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapContext;
import lu.list.itis.dkd.tui.bootstrapping.BootstrappingUtils;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.CpsNamespace;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.corona.HtmlBox;
import org.jdom2.Element;
/**
* {@link CoronaBuilder} extension building {@link HtmlBox} coronas.
*
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5.0
* @version 2.5.0
* @param <B>
* The concrete builder.
*/
@NonNullByDefault
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public abstract class BaseVariableHtmlBoxBuilder<B extends BaseVariableHtmlBoxBuilder<B>> extends BaseHtmlBoxBuilder<B> {
public String htmlTemplate;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Constructor setting the centre of the corona.
*
* @param centre
* The centre of the corona, usually the centre of the handle.
*/
// ---------------------------------------------------------------------------
public BaseVariableHtmlBoxBuilder(Point centre) {
super(centre);
}
// ---------------------------------------------------------------------------
/**
* Constructor initializing the centre of the corona as well as a possible text and the appropriate
* font size and line height ratio.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all fields
* of the builder.
* @throws BuildException
* Exception raised when the building of a corona instance cannot complete successfully due
* to the violation of one or more contracts associated with the instance, including
* missing, incomplete, or erroneous parameters or values thereof
*/
// ---------------------------------------------------------------------------
public BaseVariableHtmlBoxBuilder(Element rootElement) throws BuildException {
super(rootElement);
this.buildFromBootstrap(rootElement, null, null);
}
// ---------------------------------------------------------------------------
/**
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
public BaseVariableHtmlBoxBuilder(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
super(rootElement, context, callback);
this.buildFromBootstrap(rootElement, context, callback);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
private void buildFromBootstrap(@Nullable Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
htmlTemplate = BootstrappingUtils.getContentAsString(rootElement, CpsNamespace.HTML_TEMPLATE_NODE, BootstrappingUtils.MANDATORY, null, context);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public abstract HtmlBox build();
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import lu.list.itis.dkd.tui.bootstrapping.BootstrappingUtils;
import lu.list.itis.dkd.tui.bootstrapping.ShapeBootstrapper;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.ColorPair;
import lu.list.itis.dkd.tui.utility.CpsNamespace;
import lu.list.itis.dkd.tui.utility.Externalization;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.corona.ShapeGraph;
......@@ -38,7 +39,7 @@ public class ShapeGraphBuilder extends ValueCoronaBuilder<ShapeGraphBuilder> {
public ColorPair strokeColour;
public int strokeWidth;
public Shape graphShape;
// public SVGIcon graphImage;
public boolean blinkOnOutOfRange;
// ***************************************************************************
// * Constants *
......@@ -88,38 +89,18 @@ public class ShapeGraphBuilder extends ValueCoronaBuilder<ShapeGraphBuilder> {
/** Optional fields */
blinkOnOutOfRange = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.BLINK_ON_OUT_OF_RANGE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
strokeWidth = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.STROKE_WIDTH_NODE, BootstrappingUtils.OPTIONAL, 1, context);
fillColour = buildColorPair(rootElement.getChild(Externalization.FILL_COLOUR_ELEMENT), context);
strokeColour = buildColorPair(rootElement.getChild(Externalization.STROKE_COLOUR_ELEMENT), context);
graphShape = ShapeBootstrapper.getShape(rootElement.getChild(Externalization.SHAPE_NODE), context, callback);
// String graphImagePath = BootstrappingUtils.getContentAsString(rootElement,
// Externalization.IMAGE_ELEMENT, BootstrappingUtils.OPTIONAL, null, context);
// if (!Strings.isNullOrEmpty(graphImagePath)) {
// this.graphImage = this.loadSVGResource(graphImagePath);
// }
}
// ---------------------------------------------------------------------------
// private SVGIcon loadSVGResource(String resourcePath) {
// SVGIcon icon = null;
// try {
// URI uri = SVGCache.getSVGUniverse().loadSVG(new BufferedReader(new
// InputStreamReader(getClass().getResource(resourcePath).openStream())), "shape");
// //$NON-NLS-1$
// icon = new SVGIcon();
// icon.setSvgURI(uri);
// icon.setAntiAlias(true);
// } catch (IOException e) {
// LOGGER.error("Failed to load SVG resource {}!", resourcePath); //$NON-NLS-1$
// }
// return icon;
// }
// ---------------------------------------------------------------------------
private ColorPair buildColorPair(Element rootElement, BootstrapContext context) throws BuildException {
Color selectedColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.SELECTED_ELEMENT, BootstrappingUtils.MANDATORY, null, context);
Color deselectedColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.DESELECTED_ELEMENT, BootstrappingUtils.MANDATORY, null, context);
......
package lu.list.itis.dkd.tui.widget.corona.builder;
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapContext;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.corona.VariableHtmlBox;
import org.jdom2.Element;
/**
* Extends the static HtmlBox corona by allowing variables inside the Html content.
*
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5.0
* @version 2.5.0
*/
@NonNullByDefault
public final class VariableHtmlBoxBuilder extends BaseVariableHtmlBoxBuilder<VariableHtmlBoxBuilder> {
/**
* Constructor setting the centre of the corona.
*