Commit 5f814bae authored by Nico Mack's avatar Nico Mack

Implementation of CoxcombRangeSlice corona

parent 8c5b2289
......@@ -408,6 +408,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
shape = slice;
}
}
// ---------------------------------------------------------------------------
@Override
......
......@@ -136,6 +136,10 @@ public class Indicator extends ValueCorona {
this.shape = labelShape;
this.opacity = 1.0f;
this.horizontalOffset = 0;
if (this.variable != null) {
this.setInformation(variable.getValue());
}
}
// ---------------------------------------------------------------------------
......
......@@ -5,13 +5,12 @@ 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.utility.ValueRange;
import lu.list.itis.dkd.tui.widget.corona.builder.ValueRangeCoronaBuilder;
import lu.list.itis.dkd.tui.widget.corona.builder.BaseValueRangeCoronaBuilder;
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.List;
import java.util.Map;
......@@ -45,7 +44,7 @@ public class ValueRangeCorona extends SelectableCorona implements InformationRec
// ***************************************************************************
// ---------------------------------------------------------------------------
public ValueRangeCorona(ValueRangeCoronaBuilder<?> builder) {
public ValueRangeCorona(BaseValueRangeCoronaBuilder<?> builder) {
super(builder);
this.lowerBoundVariable = builder.lowerBoundVariable;
this.upperBoundVariable = builder.upperBoundVariable;
......@@ -95,11 +94,6 @@ public class ValueRangeCorona extends SelectableCorona implements InformationRec
// ---------------------------------------------------------------------------
@Override
public void paint(Graphics2D canvas) {}
// ---------------------------------------------------------------------------
@Override
public void setInformation(ValueRange<?> information) {
if (information != null) {
......
/**
* 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.builder;
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.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.CoxcombRangeSlice;
import org.jdom2.Element;
import java.awt.Color;
import java.awt.Font;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public abstract class BaseCoxcombRangeSliceBuilder<B extends BaseCoxcombRangeSliceBuilder<B>> extends BaseValueRangeCoronaBuilder<B> {
public String label;
public boolean radialLayout;
public boolean centered;
public boolean blinkOnOutOfRange;
public boolean faceIsTouchable;
public boolean wrapToFit;
public double innerRadius;
public double lowerBoundRadius;
public double upperBoundRadius;
public double startAngle;
public double arcSpan;
public double labelAngle;
public ColorPair fillColour;
public ColorPair strokeColour;
public ColorPair textColour;
public ColorPair faceColour;
public ColorPair bezelColour;
public Font textFont;
public int strokeWidth;
public int insetBorder;
public boolean cappedDisplay;
public int rampingTime;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param centre
*/
// ---------------------------------------------------------------------------
protected BaseCoxcombRangeSliceBuilder(Point centre) {
super(centre);
}
// ---------------------------------------------------------------------------
/**
* @param rootElement
* @throws BuildException
*/
// ---------------------------------------------------------------------------
public BaseCoxcombRangeSliceBuilder(Element rootElement) throws BuildException {
super(rootElement);
this.buildFromBootstrap(rootElement, null, null);
}
// ---------------------------------------------------------------------------
/**
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
public BaseCoxcombRangeSliceBuilder(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
super(rootElement, context, callback);
this.buildFromBootstrap(rootElement, context, callback);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
protected void buildFromBootstrap(@Nullable Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
startAngle = BootstrappingUtils.getContentAsDegrees(rootElement, Externalization.START_ANGLE_NODE, BootstrappingUtils.MANDATORY, null, context);
arcSpan = BootstrappingUtils.getContentAsDegrees(rootElement, Externalization.ARC_SPAN_NODE, BootstrappingUtils.MANDATORY, null, context);
innerRadius = BootstrappingUtils.getContentAsDouble(rootElement, Externalization.INNER_RADIUS_NODE, BootstrappingUtils.MANDATORY, null, context);
upperBoundRadius = BootstrappingUtils.getContentAsDouble(rootElement, CpsNamespace.UPPER_BOUND_RADIUS_NODE, BootstrappingUtils.MANDATORY, null, context);
lowerBoundRadius = BootstrappingUtils.getContentAsDouble(rootElement, CpsNamespace.LOWER_BOUND_RADIUS_NODE, BootstrappingUtils.MANDATORY, null, context);
fillColour = buildColorPair(rootElement.getChild(Externalization.FILL_COLOUR_ELEMENT), BootstrappingUtils.MANDATORY, context);
strokeColour = buildColorPair(rootElement.getChild(Externalization.STROKE_COLOUR_ELEMENT), BootstrappingUtils.MANDATORY, context);
/** Optional fields */
label = BootstrappingUtils.getContentAsString(rootElement, CpsNamespace.LABEL_NODE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING, context);
labelAngle = BootstrappingUtils.getContentAsDouble(rootElement, Externalization.LABEL_ANGLE_NODE, BootstrappingUtils.OPTIONAL, Double.NaN, context);
radialLayout = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.RADIAL_LAYOUT_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
centered = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.CENTRED_NODE, BootstrappingUtils.OPTIONAL, Boolean.TRUE, 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);
faceIsTouchable = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.FACE_IS_TOUCHABLE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
wrapToFit = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.WRAP_TO_FIT_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
strokeWidth = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.STROKE_WIDTH_NODE, BootstrappingUtils.OPTIONAL, 1, context);
insetBorder = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.INSET_BORDER_NODE, BootstrappingUtils.OPTIONAL, 0, context);
rampingTime = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.RAMPING_TIME_NODE, BootstrappingUtils.OPTIONAL, 500, context);
textColour = buildColorPair(rootElement.getChild(Externalization.TEXT_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
faceColour = buildColorPair(rootElement.getChild(Externalization.FACE_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
bezelColour = buildColorPair(rootElement.getChild(Externalization.BEZEL_COLOUR_ELEMENT), BootstrappingUtils.OPTIONAL, context);
String fontName = BootstrappingUtils.getContentAsString(rootElement, Externalization.FONT_NODE, BootstrappingUtils.OPTIONAL, "Monospaced"); //$NON-NLS-1$
Integer fontSize = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.FONT_SIZE_NODE, BootstrappingUtils.OPTIONAL, 14);
if ((fontName != null) && (fontName.length() > 0)) {
textFont = new Font(fontName, Font.BOLD, fontSize);
}
}
// ---------------------------------------------------------------------------
private ColorPair buildColorPair(Element rootElement, boolean optional, BootstrapContext context) throws BuildException {
ColorPair color = null;
if (rootElement == null)
return null;
Color selectedColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.SELECTED_ELEMENT, optional, null, context);
Color deselectedColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.DESELECTED_ELEMENT, optional, null, context);
color = new ColorPair(selectedColour, deselectedColour);
return color;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public abstract CoxcombRangeSlice build();
// ---------------------------------------------------------------------------
}
package lu.list.itis.dkd.tui.widget.corona.builder;
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.CoxcombRangeSlice;
import org.jdom2.Element;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.7.0
* @version 1.0.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class CoxcombRangeSliceBuilder<B extends CoxcombRangeSliceBuilder<B>> extends BaseCoxcombRangeSliceBuilder<B> {
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public CoxcombRangeSliceBuilder(Point centre) {
super(centre);
}
public CoxcombRangeSliceBuilder(Element rootElement) throws BuildException {
super(rootElement);
}
public CoxcombRangeSliceBuilder(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
super(rootElement, context, callback);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public CoxcombRangeSlice build() {
return new CoxcombRangeSlice(this);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment