Commit 8121574b authored by Nico Mack's avatar Nico Mack

Fixes to avoid CME in combination with ModalWidgets

Added fadingEnabled property to FadingCoronas for disabling fading
Added helper methods to PolarCoordinateHelper class
parent c6df8cd0
......@@ -49,6 +49,7 @@ FACE_COLOUR_ELEMENT=faceColour
FADE_IN_TIME_NODE=fadeInTime
FADE_OUT_TIME_NODE=fadeOutTime
FADE_WITH_HANDLE_NODE=fadeWithHandle
FADING_ENABLED_NODE=fadingEnabled
FILL_COLOUR_ELEMENT=fillColour
FILL_COLOUR_NODE=fillColour
FONT_NODE=font
......
......@@ -9,9 +9,12 @@ NUMBER_OF_VARIABLES_PROPERTY=NumberOfVariables
VARIABLE_ID_PROPERTY=VariableId
VARIABLE_NAME_PROPERTY=VariableName
VARIABLE_DISPLAY_NAME_PROPERTY=VariableDisplayName
VARIABLE_UNIT_PROPERTY=VariableUnit;
VARIABLE_MINVALUE_PROPERTY=VariableMinValue;
VARIABLE_MAXVALUE_PROPERTY=VariableMaxValue;
VARIABLE_UNIT_PROPERTY=VariableUnit
VARIABLE_MINVALUE_PROPERTY=VariableMinValue
VARIABLE_MAXVALUE_PROPERTY=VariableMaxValue
VARIABLE_SCALE_PROPERTY=VariableScale;
VARIABLE_COLOUR_PROPERTY=VariableColour
SIZE_OF_VECTORS_PROPERTY=SizeOfVectors
INDEX_COLOUR_PROPERTY=IndexColour
\ No newline at end of file
......@@ -84,6 +84,7 @@ public class Externalization extends NLS {
public static String FADE_IN_TIME_NODE;
public static String FADE_OUT_TIME_NODE;
public static String FADE_WITH_HANDLE_NODE;
public static String FADING_ENABLED_NODE;
public static String FILL_COLOUR_ELEMENT;
public static String FILL_COLOUR_NODE;
public static String FONT_NODE;
......
......@@ -123,9 +123,33 @@ public class PolarCoordinateHelper {
// ---------------------------------------------------------------------------
/**
* converts the specified points to a polar representation. The method computes the euclidean
* distance between both points and the comprised angle, and returns a new point representing
* the polar distance between both points.Calculations are done in origins coordinate system,
* i.e. target will be converted prior to calculation.
* distance between both points and the comprised angle, and returns a new point representing the
* polar distance between both points.Calculations are done in origins coordinate system, i.e.
* target will be converted prior to calculation.
*
* @param carthesian
* carthesian coordinates of first point
* @return a new point, with x and y value expressing the euclidean distance.
*/
// ---------------------------------------------------------------------------
public static final Point carthesianToPolar(Point carthesian) {
double x = carthesian.x;
double y = carthesian.y;
float distance = (float) Math.sqrt((x * x) + (y * y));
float angle = (float) Math.atan2(y, x);
if (angle < 0)
angle += TWO_PI;
return new Point(distance, distance, angle, carthesian.getState().getClass());
}
// ---------------------------------------------------------------------------
/**
* converts the specified points to a polar representation. The method computes the euclidean
* distance between both points and the comprised angle, and returns a new point representing the
* polar distance between both points.Calculations are done in origins coordinate system, i.e.
* target will be converted prior to calculation.
*
* @param origin
* carthesian coordinates of first point
......@@ -151,10 +175,10 @@ public class PolarCoordinateHelper {
// ---------------------------------------------------------------------------
/**
* given a point expressed in carthesian coordinates and one point expressed in polar
* coordinates, the method computes a new carthesian point corresponding to the sum of both
* input points. Calculations are done in origins coordinate system, i.e. target will be
* converted prior to calculation.
* given a point expressed in carthesian coordinates and one point expressed in polar coordinates,
* the method computes a new carthesian point corresponding to the sum of both input points.
* Calculations are done in origins coordinate system, i.e. target will be converted prior to
* calculation.
*
* @param origin
* carthesian coordinates of first point
......@@ -174,6 +198,29 @@ public class PolarCoordinateHelper {
return new Point((float) x, (float) y, 0f, origin.getState().getClass());
}
// ---------------------------------------------------------------------------
/**
* given a point expressed in carthesian coordinates and one point expressed in polar coordinates,
* the method computes a new carthesian point corresponding to the sum of both input points.
* Calculations are done in origins coordinate system, i.e. target will be converted prior to
* calculation.
*
* @param origin
* carthesian coordinates of first point
* @param polar
* polar coordinates
* @return a new point, with x and y value expressing the euclidean distance.
*/
// ---------------------------------------------------------------------------
public static final Point polarToCarthesian(Point polar) {
double x = polar.x * Math.cos(polar.getAngle());
double y = polar.y * Math.sin(polar.getAngle());
return new Point((float) x, (float) y, 0f, polar.getState().getClass());
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
......
......@@ -2,6 +2,7 @@ package lu.list.itis.dkd.tui.utility;
import org.eclipse.osgi.util.NLS;
@SuppressWarnings({"javadoc", "squid:S3008"})
public class Templating extends NLS {
private static final String BUNDLE_NAME = "templating"; //$NON-NLS-1$
......@@ -23,6 +24,8 @@ public class Templating extends NLS {
public static String VARIABLE_SCALE_PROPERTY;
public static String VARIABLE_COLOUR_PROPERTY;
public static String SIZE_OF_VECTORS_PROPERTY;
public static String INDEX_COLOUR_PROPERTY;
static {
// initialize resource bundle
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. All rights reserved.
* ntryntegerhintryntry Copyright Luxembohiurg Institute of Science and Technology, 2017. All rights
* reserved.
*
* This file is part of TULIP.
*
......@@ -28,6 +29,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
/**
* @author Nico Mack [nico.mack@list.lu]
......@@ -153,16 +155,20 @@ public class ModalWidget extends TetherableWidget {
Multimap<Integer, Corona> bundledCoronas = bundle.getCoronas();
synchronized (this.coronas) {
this.coronas.putAll(bundledCoronas);
}
if (this.onStage) {
bundledCoronas.values().forEach(corona -> corona.setActive(true));
for (Entry<Integer, Corona> entry : bundledCoronas.entries()) {
if (!this.coronas.containsEntry(entry.getKey(), entry.getValue())) {
if (this.onStage)
entry.getValue().setActive(true);
this.coronas.put(entry.getKey(), entry.getValue());
}
}
}
}
}
return activated;
}
// ---------------------------------------------------------------------------
/**
* activates the bundle with the specified name. All bundled coronas will be deactivated in the
......@@ -181,9 +187,13 @@ public class ModalWidget extends TetherableWidget {
for (CoronaBundle bundle : bundles) {
Multimap<Integer, Corona> bundledCoronas = bundle.getCoronas();
synchronized (this.coronas) {
this.coronas.removeAll(bundledCoronas);
for (Entry<Integer, Corona> entry : bundledCoronas.entries()) {
if (this.coronas.containsEntry(entry.getKey(), entry.getValue())) {
entry.getValue().setActive(false);
this.coronas.remove(entry.getKey(), entry.getValue());
}
}
}
bundledCoronas.values().forEach(corona -> corona.setActive(false));
}
}
return deactivated;
......
......@@ -36,6 +36,7 @@ import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.corona.Corona;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.TreeMultimap;
import org.jdom2.Element;
......@@ -78,7 +79,7 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
/** Constructor initialising the fields. */
public BaseBuilder() {
coronas = TreeMultimap.create();
coronas = Multimaps.synchronizedSortedSetMultimap(TreeMultimap.create());
positions = new HashMap<>();
name = Externalization.EMPTY_STRING;
tangible = true;
......@@ -86,13 +87,13 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
}
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all
* the information on fields to initialize. This constructor will add all associated handles as
* keys in the position map.
* Constructor initializing all fields from an {@link Element} containing as child elements all the
* information on fields to initialize. This constructor will add all associated handles as keys in
* the position map.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all
* fields of the builder.
* The element harbouring, on child nodes, the necessary information to initialize all fields
* of the builder.
* @throws BuildException
* Thrown when any of the fields fail to populate due to an error in reading information
* from the XML file.
......@@ -102,13 +103,13 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
}
/**
* Constructor initializing all fields from an {@link Element} containing as child elements all
* the information on fields to initialize. This constructor will add all associated handles as
* keys in the position map.
* Constructor initializing all fields from an {@link Element} containing as child elements all the
* information on fields to initialize. This constructor will add all associated handles as keys in
* the position map.
*
* @param rootElement
* The element harbouring, on child nodes, the necessary information to initialize all
* fields of the builder.
* The element harbouring, on child nodes, the necessary information to initialize all fields
* of the builder.
* @param context
* @param callback
* @throws BuildException
......@@ -222,8 +223,7 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
* Specifies whether this widget is an avatar for a tangible object or not.
*
* @param hasMultipleInstances
* specify <code>true</true> if this widget allows multiple instances with the same
* handleID.
* specify <code>true</true> if this widget allows multiple instances with the same handleID.
* @return An instance of the builder for chain calling.
*/
@SuppressWarnings("unchecked")
......
......@@ -58,9 +58,9 @@ public class FadingCorona extends Corona implements TimelineCallback, ActionList
this.fadeOutTime = builder.fadeOutTime;
this.displayTime = builder.displayTime;
this.fadeWithHandle = builder.fadeWithHandle;
this.fadingEnabled = true;
this.opacity = 0.0f;
if (displayTime > 0) {
this.fadingEnabled = builder.fadingEnabled;
this.opacity = (this.fadingEnabled) ? 0.0f : 1.0f;
if (this.fadingEnabled && (displayTime > 0)) {
displayTimer = new Timer((int) displayTime, this);
displayTimer.setRepeats(false);
}
......
......@@ -236,7 +236,7 @@ public class Sector extends SelectableCorona {
public boolean touched(TouchEvent event) {
boolean touched = false;
if (touchManager.eventInsideCorona(this, event)) {
if (isTouchable() && touchManager.eventInsideCorona(this, event)) {
touched = touchManager.touch(event);
if (touched)
this.setSelected(true);
......@@ -250,7 +250,7 @@ public class Sector extends SelectableCorona {
public boolean released(TouchEvent event) {
boolean released = false;
if (touchManager.eventInsideCorona(this, event)) {
if (isTouchable() && touchManager.eventInsideCorona(this, event)) {
released = touchManager.release(event);
if (released)
this.setSelected(false);
......
......@@ -69,6 +69,8 @@ public abstract class BaseFadingCoronaBuilder<B extends BaseFadingCoronaBuilder<
*/
public boolean fadeWithHandle;
public boolean fadingEnabled;
// ***************************************************************************
// * Constants *
// ***************************************************************************
......@@ -85,6 +87,7 @@ public abstract class BaseFadingCoronaBuilder<B extends BaseFadingCoronaBuilder<
this.fadeInTime = 0;
this.fadeOutTime = ONE_SECOND;
this.fadeWithHandle = true;
this.fadingEnabled = true;
}
/**
......@@ -118,6 +121,7 @@ public abstract class BaseFadingCoronaBuilder<B extends BaseFadingCoronaBuilder<
fadeInTime = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.FADE_IN_TIME_NODE, BootstrappingUtils.OPTIONAL, 0, context);
fadeOutTime = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.FADE_OUT_TIME_NODE, BootstrappingUtils.OPTIONAL, ONE_SECOND, context);
fadeWithHandle = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.FADE_WITH_HANDLE_NODE, BootstrappingUtils.OPTIONAL, Boolean.TRUE, context);
fadingEnabled = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.FADING_ENABLED_NODE, BootstrappingUtils.OPTIONAL, Boolean.TRUE, context);
}
// ---------------------------------------------------------------------------
......@@ -166,8 +170,8 @@ public abstract class BaseFadingCoronaBuilder<B extends BaseFadingCoronaBuilder<
* Method for specifying if the corona is to fade when the centre point is rotated.
*
* @param fades
* <code>True</code> if the corona is to fade with its centre reference,
* <code>false</code> otherwise.
* <code>True</code> if the corona is to fade with its centre reference, <code>false</code>
* otherwise.
* @return An instance of the builder for chain calling.
*/
@SuppressWarnings("unchecked")
......
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