Commit 62273dfb authored by Nico Mack's avatar Nico Mack

Added ArcRangeGraph Corona

parent fa44bf40
......@@ -14,8 +14,8 @@
package lu.list.itis.dkd.tui.bootstrapping;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.ColorFactory;
import lu.list.itis.dkd.tui.utility.Templating;
......@@ -105,13 +105,14 @@ public class DisplayWidgetBootstrapper implements BootstrapCallback {
@Override
public BootstrapContext preInstantiation(Element node, BootstrapContext context) {
context.setProperty(Templating.VARIABLE_NAME_PROPERTY, variable.getName());
context.setProperty(Templating.VARIABLE_DISPLAY_NAME_PROPERTY, variable.getDisplayName());
context.setProperty(Templating.VARIABLE_UNIT_PROPERTY, variable.getUnit());
if (variable instanceof TangibleNumericalVariable) {
TangibleNumericalVariable tangibleVariable = (TangibleNumericalVariable) variable;
context.setProperty(Templating.VARIABLE_MINVALUE_PROPERTY, tangibleVariable.getMinValue());
context.setProperty(Templating.VARIABLE_MAXVALUE_PROPERTY, tangibleVariable.getMaxValue());
context.setProperty(Templating.VARIABLE_SCALE_PROPERTY, tangibleVariable.getScale());
if (variable instanceof NumericalVariable) {
NumericalVariable numerical = (NumericalVariable) variable;
context.setProperty(Templating.VARIABLE_MINVALUE_PROPERTY, numerical.getMinValue());
context.setProperty(Templating.VARIABLE_MAXVALUE_PROPERTY, numerical.getMaxValue());
context.setProperty(Templating.VARIABLE_SCALE_PROPERTY, numerical.getScale());
}
Color colour = variableColours.get(index);
......
......@@ -15,9 +15,9 @@ package lu.list.itis.dkd.tui.bootstrapping;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.cps.variable.BooleanVariable;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.TextVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.exception.BuildException;
import org.jdom2.Element;
......@@ -43,11 +43,11 @@ public class VariableBootstrapper {
double scale = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.SCALE_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 1.0, context);
double numericValue = BootstrappingUtils.getContentAsDouble(variableNode, Externalization.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, 0.0, context);
TangibleNumericalVariable tangibleVariable = new TangibleNumericalVariable(name, unit, numericValue);
tangibleVariable.setMinValue(minValue);
tangibleVariable.setMaxValue(maxValue);
tangibleVariable.setScale(scale);
variable = tangibleVariable;
NumericalVariable numerical = new NumericalVariable(name, unit, numericValue);
numerical.setMinValue(minValue);
numerical.setMaxValue(maxValue);
numerical.setScale(scale);
variable = numerical;
break;
case Externalization.LOGIC_TYPE:
boolean booleanValue = BootstrappingUtils.getContentAsBoolean(variableNode, Externalization.INITIAL_ATTRIBUTE, BootstrappingUtils.OPTIONAL, false, context);
......
......@@ -198,7 +198,7 @@ public class EquationSystemBuilder {
variableClass = properties.getProperty(Externalization.NUMERIC_VARIABLE_CLASS);
variable = (Variable<T>) Class.forName(variableClass)
.getConstructor(String.class, String.class, double.class)
.getConstructor(String.class, String.class, Double.class)
.newInstance(name, unit, 0d);
if (!Strings.isNullOrEmpty(value))
variable.setValue(variable.valueFromString(value));
......@@ -316,9 +316,6 @@ public class EquationSystemBuilder {
private Variable<?> createVariable(HashMap<String, String> attributes) {
Variable<?> variable;
// String scale = xmlElement.getAttributeValue(Externalization.SCALE_ATTRIBUTE);
// String decimals = xmlElement.getAttributeValue(Externalization.DECIMALS_ATTRIBUTE);
variable = this.instantiateVariable(attributes.get(Externalization.NAME_ATTRIBUTE),
attributes.get(Externalization.TYPE_ATTRIBUTE),
attributes.get(Externalization.UNIT_ATTRIBUTE),
......
/**
* 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.cps.system;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import java.util.Map;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
public interface VariableBased {
public void connectWithSystemVariables(Map<String, Variable<?>> systemVariables);
}
......@@ -110,6 +110,10 @@ public class NumericalVariable extends Variable<Double> {
return builder.toString();
}
public String formatValue() {
return format.format(value / scale);
}
/**
* {@inheritDoc}<br>
* <br>
......
......@@ -386,6 +386,19 @@ public abstract class Variable<V> implements Cloneable {
this.notifyInputChangeListeners(new InputEvent(this));
}
@SuppressWarnings("unchecked")
public static <V extends Variable<?>> V castTo(Variable<?> variable, Class<V> clazz) {
V casted = null;
if (variable.getClass().isAssignableFrom(clazz)) {
casted = (V) variable;
} else {
LOGGER.error("Variable {} of type {} could not be cast to NumericalVariable!", variable.getName(), variable.getClass().getSimpleName()); //$NON-NLS-1$
}
return casted;
}
/** {@inheritDoc} */
@Override
public abstract Variable<V> clone();
......
/**
* 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.utility;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class ValueRange {
private Object lowerValue;
private Object upperValue;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public ValueRange(Object lower, Object upper) {
this.lowerValue = lower;
this.upperValue = upper;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Simple getter method for lowerValue.
*
* @return The value of lowerValue.
*/
// ---------------------------------------------------------------------------
public Object getLowerValue() {
return lowerValue;
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for lowerValue.
*
* @param lowerValue
* The value to set lowerValue to.
*/
// ---------------------------------------------------------------------------
public void setLowerValue(Object lowerValue) {
this.lowerValue = lowerValue;
}
// ---------------------------------------------------------------------------
/**
* Simple getter method for upperValue.
*
* @return The value of upperValue.
*/
// ---------------------------------------------------------------------------
public Object getUpperValue() {
return upperValue;
}
// ---------------------------------------------------------------------------
/**
* Simple setter method for upperValue.
*
* @param upperValue
* The value to set upperValue to.
*/
// ---------------------------------------------------------------------------
public void setUpperValue(Object upperValue) {
this.upperValue = upperValue;
}
}
......@@ -3,12 +3,13 @@ package lu.list.itis.dkd.tui.widget;
import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.builder.SelectorWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.IndexedCorona;
import lu.list.itis.dkd.tui.widget.corona.SelectableCorona;
import lu.list.itis.dkd.tui.widget.state.StateManager;
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
......@@ -82,16 +83,20 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
protected int getNumberOfPositions() {
List<IndexedCorona> selectableCoronas = getCoronas(IndexedCorona.class);
HashSet<Integer> alreadySeen = new HashSet<>();
List<SelectableCorona> selectableCoronas = getCoronas(SelectableCorona.class);
Multimap<Integer, SelectableCorona> alreadySeen = TreeMultimap.create();
for (IndexedCorona corona : selectableCoronas) {
for (SelectableCorona corona : selectableCoronas) {
Integer index = corona.getIndex();
Preconditions.checkArgument(!alreadySeen.contains(index), "Duplicate Index detected for indexed Corona!"); //$NON-NLS-1$
alreadySeen.add(index);
if (alreadySeen.containsKey(index)) {
for (SelectableCorona identical : alreadySeen.get(index)) {
Preconditions.checkArgument(!identical.getClass().equals(corona.getClass()), "Duplicate Index detected for indexed Corona!"); //$NON-NLS-1$
}
}
alreadySeen.put(index, corona);
}
return selectableCoronas.size();
return alreadySeen.keySet().size();
}
// ---------------------------------------------------------------------------
......@@ -103,20 +108,20 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
protected float moduloTwoPi(float rawAngle) {
double angle = rawAngle % TWO_PI;
if (angle < 0)
angle += TWO_PI;
return (float) angle;
}
// protected float moduloTwoPi(float rawAngle) {
// double angle = rawAngle % TWO_PI;
// if (angle < 0)
// angle += TWO_PI;
// return (float) angle;
//
// }
// ---------------------------------------------------------------------------
protected int getCurrentPosition(float newAngle) {
double segment = TWO_PI / numberOfPositions;
int current = 0;
float angle = this.moduloTwoPi(newAngle);
float angle = Point.moduloTwoPi(newAngle);
// detect in which segment the current rotation is
for (int position = 0; position < numberOfPositions; position++) {
......@@ -152,7 +157,7 @@ public class SelectorWidget extends ValueWidget {
protected void selectPosition(int position) {
if (position != currentPosition) {
this.getCoronas(IndexedCorona.class).forEach(indexed -> indexed.setSelected(indexed.getIndex() == position));
this.getCoronas(SelectableCorona.class).forEach(indexed -> indexed.setSelected(indexed.getIndex() == position));
if (variable != null) {
variable.setValue((double) position);
......@@ -173,7 +178,7 @@ public class SelectorWidget extends ValueWidget {
this.selectPosition(presetPosition);
Point centre = this.getPosition();
if (centre != null) {
presetAngleOffset = this.moduloTwoPi(this.getCurrentAngle(currentPosition) - (centre.getAngle() - presetAngleOffset));
presetAngleOffset = Point.moduloTwoPi(this.getCurrentAngle(currentPosition) - (centre.getAngle() - presetAngleOffset));
}
}
}
......@@ -203,7 +208,7 @@ public class SelectorWidget extends ValueWidget {
@Override
public void actionMove(TangibleObject tuioObject) {
double angle = this.moduloTwoPi(tuioObject.getAngle() + presetAngleOffset);
double angle = Point.moduloTwoPi(tuioObject.getAngle() + presetAngleOffset);
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), (float) angle));
super.actionMove(clone);
......@@ -235,7 +240,7 @@ public class SelectorWidget extends ValueWidget {
isPersistent = this.isPersistent(tuioObject.getObjectId());
int position = (isPersistent) ? currentPosition : presetPosition;
presetAngleOffset = (isPersistent) ? this.moduloTwoPi(this.getCurrentAngle(position) - tuioObject.getAngle()) : 0;
presetAngleOffset = (isPersistent) ? Point.moduloTwoPi(this.getCurrentAngle(position) - tuioObject.getAngle()) : 0;
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), presetAngleOffset));
super.actionDrop(clone);
......
......@@ -26,8 +26,8 @@ import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.content.InformationProvider;
import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.cps.utility.Externalization;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.builder.BaseValueWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona;
......@@ -69,7 +69,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
/** The value of the angle that is considered as one step. */
protected double stepSize;
/** The variable holding the value to be stored and manipulated by the widget. */
protected TangibleNumericalVariable variable;
protected NumericalVariable variable;
/** The base value to be set for the variable. */
protected double initialValue;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
......@@ -150,14 +150,14 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
private void buildFromProperties() {
if (this.variable == null) {
String variableName = ((this.name != null) && (this.name.length() > 0)) ? this.name : DEFAULT_VARIABLE;
this.variable = new TangibleNumericalVariable(variableName, Externalization.EMPTY_STRING, 0);
this.variable = new NumericalVariable(variableName, Externalization.EMPTY_STRING, 0d);
}
if (!modifyValueOnRotation) {
this.initialValue = getVariable().getInformation();
this.initialValue = getVariable().getValue();
getVariable().setValue(0d);
} else {
this.initialValue = getVariable().getInformation();
this.initialValue = getVariable().getValue();
}
constrainted = !(Double.isNaN(lowerStopAngle) || Double.isNaN(upperStopAngle));
......@@ -278,7 +278,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
@Override
public @Nullable Double getInformation(Point position) {
return variable.getInformation(position);
return variable.getValue();
}
// ---------------------------------------------------------------------------
......@@ -298,7 +298,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
*/
// ---------------------------------------------------------------------------
public TangibleNumericalVariable getVariable() {
public NumericalVariable getVariable() {
return variable;
}
......@@ -312,7 +312,7 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
*/
// ---------------------------------------------------------------------------
public void setVariable(TangibleNumericalVariable variable) {
public void setVariable(NumericalVariable variable) {
this.variable = variable;
for (ConditionalCorona conditionalCorona : getCoronas(ConditionalCorona.class)) {
......@@ -324,9 +324,9 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
public void connectWithInputs(Map<String, Variable<?>> inputs) {
if ((inputs != null) && inputs.containsKey(this.variable.getName())) {
Variable<?> input = inputs.get(this.variable.getName());
if (this.variable.getClass().isAssignableFrom(input.getClass())) {
this.variable = (TangibleNumericalVariable) input;
NumericalVariable numeric = Variable.castTo(inputs.get(this.variable.getName()), NumericalVariable.class);
if (numeric != null) {
this.variable = numeric;
}
}
}
......@@ -347,12 +347,12 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
String typeName = ((ParameterizedType) type).getActualTypeArguments()[0].getTypeName();
if (typeName.equals(String.class.getTypeName())) {
String information = (variable.getInformation() != null) ? variable.getInformation().toString() : null;
String information = (variable.getValue() != null) ? variable.getValue().toString() : null;
((InformationReceiver<String>) corona).setInformation(information);
continue;
}
if (typeName.equals(Double.class.getTypeName())) {
((InformationReceiver<Double>) corona).setInformation(variable.getInformation());
((InformationReceiver<Double>) corona).setInformation(variable.getValue());
continue;
}
}
......
......@@ -26,7 +26,7 @@ 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.bootstrapping.VariableBootstrapper;
import lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable;
import lu.list.itis.dkd.tui.cps.variable.NumericalVariable;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import lu.list.itis.dkd.tui.widget.ValueWidget;
......@@ -56,12 +56,9 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
/** The value of the angle that is considered as one step. */
public double stepSize;
/** The variable holding the value to be stored and manipulated by the widget. */
public TangibleNumericalVariable variable;
public NumericalVariable variable;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
public boolean modifyValueOnRotation = false;
/** Whether the value is dynamic, that is if it changes and is not simply triggered. */
@Deprecated
public boolean dynamic;
/**
* Simple no-arg constructor for the {@link BaseValueWidgetBuilder}.
......@@ -116,7 +113,7 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
* @throws BuildException
*/
private void buildFromBootstrap(@Nullable Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
variable = (TangibleNumericalVariable) VariableBootstrapper.buildVariableFromElement(rootElement.getChild(Externalization.VARIABLE_NODE), context, callback);
variable = (NumericalVariable) VariableBootstrapper.buildVariableFromElement(rootElement.getChild(Externalization.VARIABLE_NODE), context, callback);
modifyValueOnRotation = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.MODIFY_VALUE_ON_ROTATION_NODE, BootstrappingUtils.OPTIONAL, true, context);
if (modifyValueOnRotation) {
......@@ -190,17 +187,11 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
* @return An instance of the builder for chain-calling.
*/
@SuppressWarnings("unchecked")
public B withVariable(TangibleNumericalVariable _variable) {
public B withVariable(NumericalVariable _variable) {
this.variable = _variable;
return (B) this;
}
/*
* @SuppressWarnings("unchecked") public B variableIsDynamic(boolean dynamic) { this.dynamic =
* dynamic; return (B) this; }
*/
/** {@inheritDoc} */
@Override
public abstract ValueWidget build();
......
......@@ -34,6 +34,7 @@ import java.awt.geom.Rectangle2D;
// ***************************************************************************
public class ArcGraph extends ValueCorona {
private String title;
private double innerRadius;
private double outerRadius;
private int startAngle;
......@@ -54,6 +55,8 @@ public class ArcGraph extends ValueCorona {
private Stroke borderStroke;
private int strokeWidth;
private int rampingTime;
private Area outer;
private Area inner;
private Area arc;
......@@ -81,6 +84,8 @@ public class ArcGraph extends ValueCorona {
public ArcGraph(ArcGraphBuilder builder) {
super(builder);
this.title = builder.title;
this.startAngle = builder.startAngle;
this.arcSpan = builder.arcSpan;
this.relative = builder.relative;
......@@ -97,6 +102,7 @@ public class ArcGraph extends ValueCorona {
this.labelShape = builder.labelShape;
this.textFont = builder.textFont;
this.strokeWidth = builder.strokeWidth;
this.rampingTime = builder.rampingTime;
this.buildFromProperties();
}
......@@ -129,6 +135,7 @@ public class ArcGraph extends ValueCorona {
this.labelShape = original.labelShape;
this.textFont = original.textFont;
this.strokeWidth = original.strokeWidth;
this.rampingTime = original.rampingTime;
this.buildFromProperties();
}
......@@ -142,6 +149,10 @@ public class ArcGraph extends ValueCorona {
private void buildFromProperties() {
double diameter;
if ((this.label == null) || this.label.isEmpty()) {
this.label = this.variable.getDisplayName();
}
diameter = 2 * innerRadius;
inner = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
......@@ -287,20 +298,24 @@ public class ArcGraph extends ValueCorona {
Graphics2D localCanvas = (Graphics2D) canvas.create();
centre.toScreenCoordinates();
if (initialTranslation != null)
initialTranslation.toScreenCoordinates();
Point drawAt = centre.add(initialTranslation);
// centre.toScreenCoordinates();
// if (initialTranslation != null)
// initialTranslation.toScreenCoordinates();
// Point drawAt = centre.add(initialTranslation);
//
// if (this.rotateWithHandle) {
// angle = (float) ((drawAt.getAngle() - rotation) % TWO_PI);
// } else {
// rotation = (float) ((drawAt.getAngle() - angle) % TWO_PI);
// }
//
// AffineTransform translation = new AffineTransform();
// translation.translate(drawAt.x, drawAt.y);
// translation.rotate(angle);
AffineTransform translation = this.getTransform(null);
if (this.rotateWithHandle) {
angle = (float) ((drawAt.getAngle() - rotation) % TWO_PI);
} else {
rotation = (float) ((drawAt.getAngle() - angle) % TWO_PI);
}
AffineTransform translation = new AffineTransform();
translation.translate(drawAt.x, drawAt.y);
translation.rotate(angle);
localCanvas.setTransform(translation);
if (this.opacity < 1.0f)
......@@ -360,19 +375,24 @@ public class ArcGraph extends ValueCorona {
if (variable != null) {
double value = this.variable.getValue();
if ((balisticTimeline != null) && (!balisticTimeline.isDone()))
balisticTimeline.cancel();
if (rampingTime > 0) {
if ((balisticTimeline != null) && (!balisticTimeline.isDone()))
balisticTimeline.cancel();
balisticTimeline = new Timeline(this);
balisticTimeline.addPropertyToInterpolate("shownValue", shownValue, value); //$NON-NLS-1$
balisticTimeline.setDuration(500);
balisticTimeline.play();
balisticTimeline = new Timeline(this);
balisticTimeline.addPropertyToInterpolate("shownValue", shownValue, value); //$NON-NLS-1$
balisticTimeline.setDuration(rampingTime);
balisticTimeline.play();
} else {
this.setShownValue(value);
}
if (textFont != null) {
StringBuilder labelBuilder = new StringBuilder(this.variable.getDisplayName()).append(" "); //$NON-NLS-1$
StringBuilder labelBuilder = new StringBuilder(this.title).append(" "); //$NON-NLS-1$
labelBuilder.append(this.variable.toString());
this.label = labelBuilder.toString();
this.labelMetrics = textFont.getLineMetrics(label.toString(), new FontRenderContext(null, true, true));
this.labelMetrics = textFont.getLineMetrics(this.label, new FontRenderContext(null, true, true));
}
}
}
......
This diff is collapsed.
package lu.list.itis.dkd.tui.widget.corona;
import lu.list.itis.dkd.tui.content.InformationReceiver;
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 org.python.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Graphics2D;
import java.util.Map;
/**
* @author nmack
* @param <B>
* @date 20 Jan 2016
*
* <br>
* $Log: DisplayCorona.java,v $
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class ValueRangeCorona extends Corona implements InformationReceiver<ValueRange>, VariableBased {
protected NumericalVariable lowerBoundVariable;
protected NumericalVariable upperBoundVariable;
protected boolean selected;
// ***************************************************************************
// * Constants *
// ***************************************************************************
private static final Logger LOGGER = LoggerFactory.getLogger(ValueRangeCorona.class.getSimpleName());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
public ValueRangeCorona(ValueRangeCoronaBuilder<?> builder) {
super(builder);
this.lowerBoundVariable = builder.lowerBoundVariable;
this.upperBoundVariable = builder.upperBoundVariable;
this.selected = false;
}
// ---------------------------------------------------------------------------
public ValueRangeCorona(ValueRangeCorona original) {
super(original);
this.lowerBoundVariable = (original.lowerBoundVariable != null) ? original.lowerBoundVariable.clone() : null;
this.upperBoundVariable = (original.upperBoundVariable != null) ? original.upperBoundVariable.clone() : null;
this.selected = false;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
public NumericalVariable getLowerBoundVariable() {
return this.lowerBoundVariable;
}
// ---------------------------------------------------------------------------
public void setLowerBoundVariable(NumericalVariable variable) {
<