Commit 4054df5e authored by Nico Mack's avatar Nico Mack

Integrated touch capabilities into Content

parent 244169f6
......@@ -50,7 +50,7 @@ public class StageManager {
// * Constants
// ***************************************************************************
private static final int TANGIBLE_INTERFACE_STAGE_ID = 0;
public static final int TANGIBLE_INTERFACE_STAGE_ID = 0;
protected static final Logger LOGGER = LoggerFactory.getLogger(StageManager.class.getSimpleName());
......
......@@ -29,6 +29,7 @@ import lu.list.itis.dkd.tui.utility.StringUtils;
import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.tether.Tether;
import lu.list.itis.dkd.tui.widget.touch.TouchEvent;
import lu.list.itis.dkd.tui.widget.touch.Touchable;
import com.google.common.base.Preconditions;
......@@ -164,6 +165,18 @@ public abstract class TangibleObjectManager {
break;
}
}
if (!takenCareOf) {
List<Touchable> touchableContent = this.tangibleApplication.contentManager.getContent(Touchable.class, StageManager.TANGIBLE_INTERFACE_STAGE_ID);
for (Touchable touchable : touchableContent) {
if (touchable.isTouchable()) {
takenCareOf |= touchable.touched(event);
if (takenCareOf)
break;
}
}
}
}
return takenCareOf;
}
......@@ -185,6 +198,19 @@ public abstract class TangibleObjectManager {
break;
}
}
if (!takenCareOf) {
List<Touchable> touchableContent = this.tangibleApplication.contentManager.getContent(Touchable.class, StageManager.TANGIBLE_INTERFACE_STAGE_ID);
for (Touchable touchable : touchableContent) {
if (touchable.isTouchable()) {
takenCareOf |= touchable.dragged(event);
if (takenCareOf)
break;
}
}
}
}
return takenCareOf;
}
......@@ -204,6 +230,19 @@ public abstract class TangibleObjectManager {
takenCareOf |= widget.released(event);
}
}
if (!takenCareOf) {
List<Touchable> touchableContent = this.tangibleApplication.contentManager.getContent(Touchable.class, StageManager.TANGIBLE_INTERFACE_STAGE_ID);
for (Touchable touchable : touchableContent) {
if (touchable.isTouchable()) {
takenCareOf |= touchable.released(event);
if (takenCareOf)
break;
}
}
}
}
return takenCareOf;
}
......
......@@ -44,6 +44,7 @@ public class ShapeCorona extends Corona {
private Color fillColour;
private Color strokeColour;
private int strokeWidth = 0;
private Stroke borderStroke;
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -64,6 +65,8 @@ public class ShapeCorona extends Corona {
fillColour = builder.fillColour;
strokeColour = builder.strokeColour;
strokeWidth = builder.strokeWidth;
borderStroke = (builder.strokeWidth > 0) ? new BasicStroke(strokeWidth) : null;
}
// ---------------------------------------------------------------------------
......@@ -81,6 +84,8 @@ public class ShapeCorona extends Corona {
fillColour = original.fillColour;
strokeColour = original.strokeColour;
strokeWidth = original.strokeWidth;
borderStroke = (original.strokeWidth > 0) ? new BasicStroke(strokeWidth) : null;
}
// ---------------------------------------------------------------------------
......@@ -104,7 +109,8 @@ public class ShapeCorona extends Corona {
canvas.setPaint(strokeColour);
Stroke oldStroke = canvas.getStroke();
canvas.setStroke(new BasicStroke(strokeWidth));
if (borderStroke != null)
canvas.setStroke(borderStroke);
canvas.draw(transformedShape);
canvas.setStroke(oldStroke);
}
......
......@@ -197,12 +197,22 @@ public class TouchManager implements ActionListener {
// ---------------------------------------------------------------------------
public boolean isMultitouch() {
return (getTouchCount() > 1);
}
// ---------------------------------------------------------------------------
/**
* @return
*/
// ---------------------------------------------------------------------------
public int getTouchCount() {
int count = 0;
for (Touch touch : this.touches.values()) {
count += (touch.getState().equals(FiniteStateMachine.RELEASED_STATE)) ? 0 : 1;
}
return (count > 1);
return count;
}
// ---------------------------------------------------------------------------
......
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