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

Bug Fixes and improvements

parent ee78ff8e
......@@ -16,6 +16,7 @@ BORDER_THICKNESS_NODE=borderThickness
BORDER_WIDTH_NODE=borderWidth
BOUNDS_NODE=bounds
BUILDER_CLASS_POSTFIX=Builder
CAPPED_DISPLAY_NODE=cappedDisplay
CENTER_ON_ZOOM_NODE=centerOnZoom
CENTRE_NODE=centre
CENTRED_NODE=centred
......
......@@ -145,6 +145,8 @@ public class TangibleInterfaceManager extends Stage {
if (calibration != null) {
calibrationFileURI = calibration;
}
Calibration.loadFromFile(calibrationFileURI);
/**
* Checks added due to missing contracts on inherited or implemented classes or interfaces.
......@@ -180,6 +182,12 @@ public class TangibleInterfaceManager extends Stage {
*/
@Override
public void setupWindow() {
if (!fullScreen) {
this.bounds.width = Calibration.getWindowWidth();
this.bounds.height = Calibration.getWindowHeight();
}
super.setupWindow();
splashScreen = new SplashScreen(this.bounds.width, this.bounds.height);
}
......@@ -188,6 +196,10 @@ public class TangibleInterfaceManager extends Stage {
public void showWindow() {
super.showWindow();
this.showSplashScreen();
if (!fullScreen) {
window.setLocation(Calibration.getTopLeftXCoordinate(), Calibration.getTopLeftYCoordinate());
}
}
protected void showSplashScreen() {
......
......@@ -63,8 +63,8 @@ public class BootstrappingUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(BootstrappingUtils.class.getSimpleName());
private static final String DEGREES = "deg";
private static final String RADIANS = "rad";
private static final String DEGREES = "deg"; //$NON-NLS-1$
private static final String RADIANS = "rad"; //$NON-NLS-1$
// ---------------------------------------------------------------------------
// ***************************************************************************
......
......@@ -194,7 +194,7 @@ public class Stage extends JComponent {
}
this.name = BootstrappingUtils.getContentAsString(stageNode, Externalization.NAME_NODE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING, context);
this.fullScreen = BootstrappingUtils.getContentAsBoolean(stageNode, Externalization.FULLSCREEN_NODE, BootstrappingUtils.OPTIONAL, Boolean.TRUE, context);
this.fullScreen = BootstrappingUtils.getContentAsBoolean(stageNode, Externalization.FULLSCREEN_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
this.backgroundColour = BootstrappingUtils.getContentAsColour(stageNode, Externalization.BACKGROUND_COLOUR_NODE, BootstrappingUtils.OPTIONAL, Color.BLACK, context);
this.bounds = buildBoundsFromElement(stageNode.getChild(Externalization.BOUNDS_NODE), context, callback);
......
......@@ -51,6 +51,7 @@ public class Externalization extends NLS {
public static String BORDER_WIDTH_NODE;
public static String BOUNDS_NODE;
public static String BUILDER_CLASS_POSTFIX;
public static String CAPPED_DISPLAY_NODE;
public static String CENTER_ON_ZOOM_NODE;
public static String CENTRE_NODE;
public static String CENTRED_NODE;
......
......@@ -62,6 +62,7 @@ public class Point extends Float implements KdComparator<Point> {
protected static final double PI_HALF = Math.PI / 2;
protected static final double THREE_PI_HALF = 1.5 * Math.PI;
protected static final double TWO_PI = 2 * Math.PI;
protected static final double THREE_SIXTY = 360;
private static final Logger logger = LoggerFactory.getLogger(Point.class.getSimpleName());
......@@ -329,21 +330,6 @@ public class Point extends Float implements KdComparator<Point> {
this.state = state;
}
/**
* @param rawAngle
* @return
*/
public static float moduloTwoPi(float rawAngle) {
double angle = rawAngle % TWO_PI;
if (angle < 0)
angle += TWO_PI;
return (float) angle;
}
/**
* Method for testing the equality of two points as neither equals not hashCode can be
* implemented due to the objects high mutability. This test for equality ignores orientation
......
......@@ -143,6 +143,8 @@ public class PolarCoordinateHelper {
double y = clone.y - origin.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, origin.getState().getClass());
}
......
......@@ -52,8 +52,6 @@ import java.util.stream.Stream;
public class StatefulWidget extends BaseWidget {
/** The coalesced NuiState instances per handle. */
protected ConcurrentHashMap<Integer, StateManager> states;
/** Fields to track changes in position and rotation. */
// protected Point rotationDelta, movementDelta;
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -70,8 +68,6 @@ public class StatefulWidget extends BaseWidget {
super(builder);
Preconditions.checkState(builder.states != null);
states = builder.states;
// rotationDelta = new Point(0, 0, 0);
// movementDelta = new Point(0, 0, 0);
}
// ---------------------------------------------------------------------------
......@@ -91,8 +87,6 @@ public class StatefulWidget extends BaseWidget {
boolean isPersistent = entry.getValue().isPersistent();
states.putIfAbsent(entry.getKey(), new StateManager(isPersistent));
}
// rotationDelta = new Point(0, 0, 0);
// movementDelta = new Point(0, 0, 0);
}
// ---------------------------------------------------------------------------
......
......@@ -116,6 +116,10 @@ public abstract class Corona implements Comparable<Corona>, Cloneable, Touchable
protected static final double THREE_PI_HALF = 1.5 * Math.PI;
protected static final double TWO_PI = 2 * Math.PI;
protected static final double THREE_SIXTY = 360d;
protected static final double ONE_EIGHTY = 180d;
private static final Logger LOGGER = LoggerFactory.getLogger(Corona.class.getSimpleName());
// ---------------------------------------------------------------------------
......
package lu.list.itis.dkd.tui.widget.corona;
import lu.list.itis.dkd.tui.utility.AngleUtils;
import lu.list.itis.dkd.tui.utility.ColorPair;
import lu.list.itis.dkd.tui.utility.PolarCoordinateHelper;
import lu.list.itis.dkd.tui.utility.TextStroke;
import lu.list.itis.dkd.tui.widget.corona.builder.SectorBuilder;
import lu.list.itis.dkd.tui.widget.touch.TouchEvent;
......@@ -50,7 +52,6 @@ public class Sector extends SelectableCorona {
protected Shape curvedText;
protected Stroke borderStroke;
protected Font textFont;
protected Area sector;
protected TouchManager touchManager;
......@@ -80,7 +81,7 @@ public class Sector extends SelectableCorona {
textColour = builder.textColour;
textFont = builder.textFont;
gap = builder.gap;
startAngle = builder.startAngle;
this.startAngle = builder.startAngle;
arcSpan = builder.arcSpan;
this.buildSectorFromProperties();
......@@ -124,24 +125,29 @@ public class Sector extends SelectableCorona {
// ---------------------------------------------------------------------------
private void buildSectorFromProperties() {
startAngle -= (gap / 2);
arcSpan = -(arcSpan - (gap / 2));
size = 2 * outerRadius;
double angle = AngleUtils.moduloThreeSixty(startAngle);
// startAngle = (90 - startAngle);
if (startAngle < 0)
startAngle += 360;
if (startAngle > 360)
startAngle -= 360;
angle += ((double) gap / 2);
arcSpan -= gap;
sector = new Area(new Arc2D.Double(-outerRadius, -outerRadius, size, size, startAngle, arcSpan, Arc2D.PIE));
int quadrant = PolarCoordinateHelper.getQuadrant(Math.toRadians(angle));
boolean flipped = (quadrant == 2) || (quadrant == 3);
// Java Arc3D start angle and extend are expressed in counter clockwise rotation. Since
// TULIP follows the clockwise TUIO convention, we need to convert both startAngle and
// extend.
angle = (THREE_SIXTY - angle);
Area pie = new Area(new Arc2D.Double(-outerRadius, -outerRadius, size, size, angle, -arcSpan, Arc2D.PIE));
Area background = new Area(new Ellipse2D.Double(-outerRadius, -outerRadius, size, size));
Area hole = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2));
sector.subtract(hole);
pie.subtract(hole);
background.subtract(hole);
shape = pie;
shape = sector;
borderStroke = (strokeWidth > 0) ? new BasicStroke(strokeWidth) : null;
if ((label != null) && (label.length() > 0)) {
......@@ -149,12 +155,11 @@ public class Sector extends SelectableCorona {
LineMetrics metrics = textFont.getLineMetrics(label, renderingContext);
double labelRadius = outerRadius - metrics.getAscent() / 2;
boolean flipped = (startAngle >= 30) && (startAngle <= 150);
Rectangle2D bounds = new Rectangle2D.Double(centre.x - labelRadius, centre.y - labelRadius, (2 * labelRadius), (2 * labelRadius));
int start = (!flipped) ? startAngle + arcSpan : startAngle;
int length = (!flipped) ? -arcSpan : arcSpan;
double start = (!flipped) ? angle - arcSpan : angle;
int length = (!flipped) ? arcSpan : -arcSpan;
Shape path = new Arc2D.Double(bounds, start, length, Arc2D.OPEN);
......@@ -200,7 +205,7 @@ public class Sector extends SelectableCorona {
AffineTransform transform = this.getTransform(null);
Shape transformed = transform.createTransformedShape(sector);
Shape transformed = transform.createTransformedShape(shape);
if (this.opacity < 1.0f)
localCanvas.setComposite(AlphaComposite.SrcOver.derive(this.opacity));
......@@ -227,6 +232,7 @@ public class Sector extends SelectableCorona {
// ---------------------------------------------------------------------------
@Override
public boolean touched(TouchEvent event) {
boolean touched = false;
......@@ -240,6 +246,7 @@ public class Sector extends SelectableCorona {
// ---------------------------------------------------------------------------
@Override
public boolean released(TouchEvent event) {
boolean released = false;
......
......@@ -203,6 +203,8 @@ public class TouchManager {
if (newState != oldState)
this.touchStates.put(touchId, newState);
dragged = (newState == DRAGGED_STATE);
if (dragged)
lastTouch = event.getPosition();
}
return dragged;
}
......@@ -238,6 +240,13 @@ public class TouchManager {
return released;
}
// ---------------------------------------------------------------------------
public void clear() {
lastTouch = null;
this.touchStates.clear();
}
// ---------------------------------------------------------------------------
/**
* @param canvas
......
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