[FEAT] continue refacto to manage distinct width in rectangle border

This commit is contained in:
Edouard DUPIN 2025-07-15 23:30:28 +02:00
parent ec4b1a1875
commit 55664d759e
9 changed files with 695 additions and 256 deletions

View File

@ -15,6 +15,8 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f; import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.Dimension3f; import org.atriasoft.etk.Dimension3f;
import org.atriasoft.etk.DimensionBorderRadius;
import org.atriasoft.etk.DimensionInsets;
import org.atriasoft.etk.Distance; import org.atriasoft.etk.Distance;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
@ -1135,6 +1137,294 @@ public class ModelWidget extends Container {
} }
} }
public void addMenuDimensionBorderRadius(final Widget widget, final IntrospectionProperty pojo) {
Object valueRaw = null;
try {
valueRaw = pojo.getValue(widget);
} catch (final AknotException e) {
e.printStackTrace();
return;
}
if (valueRaw instanceof final DimensionBorderRadius value) {
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("bottom-left");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().bottomLeft());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionBorderRadius castedValue) {
castedValue = castedValue.withSize(castedValue.size().withBottomLeft(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("bottom-right");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().bottomRight());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionBorderRadius castedValue) {
castedValue = castedValue.withSize(castedValue.size().withBottomRight(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("top-right");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().topRight());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionBorderRadius castedValue) {
castedValue = castedValue.withSize(castedValue.size().withTopRight(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("top-left");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().topLeft());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionBorderRadius castedValue) {
castedValue = castedValue.withSize(castedValue.size().withTopLeft(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
}
}
public void addMenuDimensionInsets(final Widget widget, final IntrospectionProperty pojo) {
Object valueRaw = null;
try {
valueRaw = pojo.getValue(widget);
} catch (final AknotException e) {
e.printStackTrace();
return;
}
if (valueRaw instanceof final DimensionInsets value) {
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("left");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().left());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionInsets castedValue) {
castedValue = castedValue.withSize(castedValue.size().withLeft(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("bottom");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().bottom());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionInsets castedValue) {
castedValue = castedValue.withSize(castedValue.size().withBottom(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("right");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().right());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionInsets castedValue) {
castedValue = castedValue.withSize(castedValue.size().withRight(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
{
final var lineSizer = new Sizer(DisplayMode.HORIZONTAL);
lineSizer.setPropertyExpand(Vector2b.TRUE_FALSE);
lineSizer.setPropertyFill(Vector2b.TRUE);
this.sizerMenu.subWidgetAdd(lineSizer);
final var simpleLabel = new Label("top");
simpleLabel.setPropertyExpand(Vector2b.FALSE);
simpleLabel.setPropertyFill(Vector2b.TRUE);
simpleLabel.setPropertyMinSize(new Dimension2f(Vector2f.VALUE_16, Distance.PIXEL));
simpleLabel.setPropertyGravity(Gravity.LEFT);
lineSizer.subWidgetAdd(simpleLabel);
final var spin = new Spin();
spin.setPropertyExpand(Vector2b.TRUE_FALSE);
spin.setPropertyFill(Vector2b.TRUE);
spin.setPropertyValue((int) value.size().top());
lineSizer.subWidgetAdd(spin);
final var con = spin.signalValue.connect(newValue -> {
try {
final var oldValue = pojo.getValue(widget);
if (oldValue instanceof DimensionInsets castedValue) {
castedValue = castedValue.withSize(castedValue.size().withTop(newValue));
LOGGER.warn("Set new value: {}", castedValue);
pojo.setExistingValue(widget, castedValue);
}
} catch (final AknotException e) {
e.printStackTrace();
return;
}
});
this.conections.add(con);
}
}
}
public void displayAllPropertyWithType(final Widget widget, final IntrospectionModel modelPojo) throws Exception { public void displayAllPropertyWithType(final Widget widget, final IntrospectionModel modelPojo) throws Exception {
LOGGER.warn("Connect all property(ies) on '{}'", widget.getName()); LOGGER.warn("Connect all property(ies) on '{}'", widget.getName());
final var atributes = modelPojo.getAttributes(); final var atributes = modelPojo.getAttributes();
@ -1175,6 +1465,10 @@ public class ModelWidget extends Container {
addMenuDimension2f(widget, pojo); addMenuDimension2f(widget, pojo);
} else if (pojo.getType() == Dimension1f.class) { } else if (pojo.getType() == Dimension1f.class) {
addMenuDimension1f(widget, pojo); addMenuDimension1f(widget, pojo);
} else if (pojo.getType() == DimensionBorderRadius.class) {
addMenuDimensionBorderRadius(widget, pojo);
} else if (pojo.getType() == DimensionInsets.class) {
addMenuDimensionInsets(widget, pojo);
} else if (pojo.getType() == DisplayMode.class) { } else if (pojo.getType() == DisplayMode.class) {
LOGGER.error(" ==> plop"); LOGGER.error(" ==> plop");
} else if (pojo.getType() == Uri.class) { } else if (pojo.getType() == Uri.class) {

View File

@ -1,8 +1,9 @@
package sample.atriasoft.ewol; package sample.atriasoft.ewol;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.DimensionBorderRadius;
import org.atriasoft.etk.DimensionInsets;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.widget.Box; import org.atriasoft.ewol.widget.Box;
@ -22,8 +23,8 @@ public class TestWidgetBox implements TestWidgetInterface {
final var testWidget = new Box(innerWidget); final var testWidget = new Box(innerWidget);
testWidget.setPropertyExpand(Vector2b.FALSE); testWidget.setPropertyExpand(Vector2b.FALSE);
testWidget.setPropertyFill(Vector2b.FALSE); testWidget.setPropertyFill(Vector2b.FALSE);
testWidget.setPropertyBorderWidth(new Dimension1f(10)); testWidget.setPropertyBorderWidth(new DimensionInsets(10));
testWidget.setPropertyBorderRadius(new Dimension1f(25)); testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
testWidget.setPropertyBorderColor(Color.BLACK); testWidget.setPropertyBorderColor(Color.BLACK);
testWidget.setPropertyColor(Color.GREEN_YELLOW); testWidget.setPropertyColor(Color.GREEN_YELLOW);
testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15))); testWidget.setPropertyPadding(new Dimension2f(new Vector2f(15, 15)));

View File

@ -5,7 +5,9 @@
*/ */
package org.atriasoft.ewol.compositing; package org.atriasoft.ewol.compositing;
import org.atriasoft.etk.BorderRadius;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Insets;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
public interface CompositingDrawInterface { public interface CompositingDrawInterface {
@ -28,5 +30,7 @@ public interface CompositingDrawInterface {
void addCircle(final Vector2f position, final float radius); void addCircle(final Vector2f position, final float radius);
void addEllipse(final Vector2f center, final Vector2f radius); void addEllipse(final Vector2f center, final Vector2f radius);
void addRectangle(Vector2f position, Vector2f size, Insets thickness, BorderRadius radius);
} }

View File

@ -8,7 +8,9 @@ package org.atriasoft.ewol.compositing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.atriasoft.etk.BorderRadius;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Insets;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
@ -22,7 +24,7 @@ import org.slf4j.LoggerFactory;
public abstract class CompositingDrawing extends CompositingDraw { public abstract class CompositingDrawing extends CompositingDraw {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class); private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class);
protected static int vboIdColor = 1; protected static int vboIdColor = 1;
protected static int vboIdCoord = 0; protected static int vboIdCoord = 0;
private boolean clippingEnable = false; // !< true if the clipping must be activated private boolean clippingEnable = false; // !< true if the clipping must be activated
@ -38,19 +40,19 @@ public abstract class CompositingDrawing extends CompositingDraw {
private ResourceProgram oGLprogram; // !< pointer on the opengl display program private ResourceProgram oGLprogram; // !< pointer on the opengl display program
private final List<Color> outColors = new ArrayList<>(); private final List<Color> outColors = new ArrayList<>();
private final List<Vector3f> outTriangles = new ArrayList<>(); private final List<Vector3f> outTriangles = new ArrayList<>();
private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw
private float thickness = 0; // !< when drawing line and other things private float thickness = 0; // !< when drawing line and other things
private final Vector3f[] triangle = new Vector3f[3]; // !< Register every system with a combinaison of tiangle private final Vector3f[] triangle = new Vector3f[3]; // !< Register every system with a combinaison of tiangle
private final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground private final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground
private int triElement = 0; // !< special counter of the single dot generated private int triElement = 0; // !< special counter of the single dot generated
//protected ResourceVirtualBufferObject vbo; //protected ResourceVirtualBufferObject vbo;
protected ResourceVirtualArrayObject vbo; protected ResourceVirtualArrayObject vbo;
// internal API for the generation abstraction of triangles // internal API for the generation abstraction of triangles
/** /**
* Basic ructor * Basic ructor
@ -66,7 +68,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of ewol::compositing::Area"); this.vbo.setName("[VBO] of ewol::compositing::Area");
} }
/** /**
* add a point reference at the current position (this is a vertex * add a point reference at the current position (this is a vertex
* reference at the current position * reference at the current position
@ -75,7 +77,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
internalSetColor(this.color); internalSetColor(this.color);
setPoint(this.position); setPoint(this.position);
} }
/** /**
* draw a 2D circle with the specify rafdius parameter. * draw a 2D circle with the specify rafdius parameter.
* @param radius Distence to the dorder * @param radius Distence to the dorder
@ -85,15 +87,25 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void circle(final float radius) { public void circle(final float radius) {
circle(radius, 0); circle(radius, 0);
} }
public void circle(final float radius, final float angleStart) { public void circle(final float radius, final float angleStart) {
circle(radius, angleStart, 2.0f * FMath.PI); circle(radius, angleStart, 2.0f * FMath.PI);
} }
public void circleBorderRaw(
final Vector3f centerPos,
final float radius,
final float thickness,
final float angleStart,
final float angleStop) {
circleBorderRaw(centerPos, radius, thickness, thickness, angleStart, angleStop);
}
public void circleBorderRaw( public void circleBorderRaw(
final Vector3f centerPos, final Vector3f centerPos,
final float radius, final float radius,
final float thickness, final float thicknessStart,
final float thicknessStop,
final float angleStart, final float angleStart,
final float angleStop) { final float angleStop) {
resetCount(); resetCount();
@ -102,6 +114,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
nbOcurence = 10; nbOcurence = 10;
} }
for (int iii = 0; iii < nbOcurence; iii++) { for (int iii = 0; iii < nbOcurence; iii++) {
final float thickness = thicknessStart + ((thicknessStart - thicknessStop) * iii / nbOcurence);
final float angleOne = angleStart + (angleStop * iii / nbOcurence); final float angleOne = angleStart + (angleStop * iii / nbOcurence);
final float offsetExty = FMath.sin(angleOne) * (radius + thickness / 2); final float offsetExty = FMath.sin(angleOne) * (radius + thickness / 2);
final float offsetExtx = FMath.cos(angleOne) * (radius + thickness / 2); final float offsetExtx = FMath.cos(angleOne) * (radius + thickness / 2);
@ -119,46 +132,56 @@ public abstract class CompositingDrawing extends CompositingDraw {
setPoint(new Vector3f(centerPos.x() + offsetInt2x, centerPos.y() + offsetInt2y, 0)); setPoint(new Vector3f(centerPos.x() + offsetInt2x, centerPos.y() + offsetInt2y, 0));
setPoint(new Vector3f(centerPos.x() + offsetIntx, centerPos.y() + offsetInty, 0)); setPoint(new Vector3f(centerPos.x() + offsetIntx, centerPos.y() + offsetInty, 0));
} }
} }
public void circleRaw(final Vector3f centerPos, final float radius, final float angleStart, final float angleStop) { public void circleRaw(final Vector3f centerPos, final float radius, final float angleStart, final float angleStop) {
circleRaw(centerPos, radius, radius, angleStart, angleStop);
}
public void circleRaw(
final Vector3f centerPos,
final float radiusStart,
final float radiusStop,
final float angleStart,
final float angleStop) {
resetCount(); resetCount();
int nbOcurence = (int) radius; int nbOcurence = (int) FMath.max(radiusStart, radiusStop);
if (nbOcurence < 10) { if (nbOcurence < 10) {
nbOcurence = 10; nbOcurence = 10;
} }
final float invertOccurence = 1.0f / nbOcurence;
for (int iii = 0; iii < nbOcurence; iii++) { for (int iii = 0; iii < nbOcurence; iii++) {
final float radius = radiusStart + ((radiusStart - radiusStop) * iii * invertOccurence);
setPoint(new Vector3f(centerPos.x(), centerPos.y(), 0)); setPoint(new Vector3f(centerPos.x(), centerPos.y(), 0));
final float angleOne = angleStart + (angleStop * iii / nbOcurence); final float angleOne = angleStart + (angleStop * iii * invertOccurence);
float offsety = FMath.sin(angleOne) * radius; float offsety = FMath.sin(angleOne) * radius;
float offsetx = FMath.cos(angleOne) * radius; float offsetx = FMath.cos(angleOne) * radius;
setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0)); setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0));
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence); final float angleTwo = angleStart + (angleStop * (iii + 1) * invertOccurence);
offsety = FMath.sin(angleTwo) * radius; offsety = FMath.sin(angleTwo) * radius;
offsetx = FMath.cos(angleTwo) * radius; offsetx = FMath.cos(angleTwo) * radius;
setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0)); setPoint(new Vector3f(centerPos.x() + offsetx, centerPos.y() + offsety, 0));
} }
} }
public void circle(float radius, final float angleStart, float angleStop) { public void circle(float radius, final float angleStart, float angleStop) {
resetCount(); resetCount();
if (radius < 0) { if (radius < 0) {
radius *= -1; radius *= -1;
} }
angleStop = angleStop - angleStart; angleStop = angleStop - angleStart;
// display background : // display background :
if (this.colorBg.a() != 0) { if (this.colorBg.a() != 0) {
internalSetColor(this.colorBg); internalSetColor(this.colorBg);
circleRaw(this.position, radius, angleStart, angleStop); circleRaw(this.position, radius, angleStart, angleStop);
} }
// show if we have a border : // show if we have a border :
if (this.thickness == 0 || this.color.a() == 0) { if (this.thickness == 0 || this.color.a() == 0) {
return; return;
@ -166,7 +189,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
internalSetColor(this.color); internalSetColor(this.color);
circleBorderRaw(this.position, radius, this.thickness, angleStart, angleStop); circleBorderRaw(this.position, radius, this.thickness, angleStart, angleStop);
} }
/** /**
* clear all the registered element in the current element * clear all the registered element in the current element
*/ */
@ -178,23 +201,23 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.vbo.clear(); this.vbo.clear();
this.outTriangles.clear(); this.outTriangles.clear();
this.outColors.clear(); this.outColors.clear();
// reset temporal variables : // reset temporal variables :
this.position = Vector3f.ZERO; this.position = Vector3f.ZERO;
this.clippingPosStart = Vector3f.ZERO; this.clippingPosStart = Vector3f.ZERO;
this.clippingPosStop = Vector3f.ZERO; this.clippingPosStop = Vector3f.ZERO;
this.clippingEnable = false; this.clippingEnable = false;
this.color = Color.BLACK; this.color = Color.BLACK;
this.colorBg = Color.NONE; this.colorBg = Color.NONE;
for (int iii = 0; iii < 3; iii++) { for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position; this.triangle[iii] = this.position;
this.tricolor[iii] = this.color; this.tricolor[iii] = this.color;
} }
} }
/** /**
* draw All the refistered text in the current element on openGL * draw All the refistered text in the current element on openGL
*/ */
@ -217,7 +240,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void flush() { public void flush() {
// push data on the VBO // push data on the VBO
@ -225,7 +248,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.vbo.setColors(this.outColors.toArray(Color[]::new)); this.vbo.setColors(this.outColors.toArray(Color[]::new));
this.vbo.setVertexCount(this.outTriangles.size()); this.vbo.setVertexCount(this.outTriangles.size());
} }
/** /**
* Lunch the generation of triangle * Lunch the generation of triangle
*/ */
@ -238,7 +261,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.outColors.add(this.tricolor[1]); this.outColors.add(this.tricolor[1]);
this.outColors.add(this.tricolor[2]); this.outColors.add(this.tricolor[2]);
} }
/** /**
* Get the foreground color of the font. * Get the foreground color of the font.
* @return Foreground color. * @return Foreground color.
@ -246,7 +269,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public Color getColor() { public Color getColor() {
return this.color; return this.color;
} }
/** /**
* Get the background color of the font. * Get the background color of the font.
* @return Background color. * @return Background color.
@ -254,7 +277,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public Color getColorBg() { public Color getColorBg() {
return this.colorBg; return this.colorBg;
} }
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -262,7 +285,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
/** /**
* set the Color of the current triangle drawing * set the Color of the current triangle drawing
* @param color Color to current dots generated * @param color Color to current dots generated
@ -278,7 +301,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.tricolor[2] = color; this.tricolor[2] = color;
} }
} }
/** /**
* Relative drawing a line (special vector) * Relative drawing a line (special vector)
* @param vect Vector of the current line. * @param vect Vector of the current line.
@ -286,31 +309,31 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void lineRel(final float xxx, final float yyy) { public void lineRel(final float xxx, final float yyy) {
lineTo(this.position.add(new Vector3f(xxx, yyy, 0))); lineTo(this.position.add(new Vector3f(xxx, yyy, 0)));
} }
public void lineRel(final float xxx, final float yyy, final float zzz) { public void lineRel(final float xxx, final float yyy, final float zzz) {
lineTo(this.position.add(new Vector3f(xxx, yyy, zzz))); lineTo(this.position.add(new Vector3f(xxx, yyy, zzz)));
} }
public void lineRel(final Vector2f vect) { public void lineRel(final Vector2f vect) {
lineRel(new Vector3f(vect.x(), vect.y(), 0)); lineRel(new Vector3f(vect.x(), vect.y(), 0));
} }
public void lineRel(final Vector3f vect) { public void lineRel(final Vector3f vect) {
lineTo(this.position.add(vect)); lineTo(this.position.add(vect));
} }
public void lineTo(final float xxx, final float yyy) { public void lineTo(final float xxx, final float yyy) {
lineTo(new Vector3f(xxx, yyy, 0)); lineTo(new Vector3f(xxx, yyy, 0));
} }
public void lineTo(final float xxx, final float yyy, final float zzz) { public void lineTo(final float xxx, final float yyy, final float zzz) {
lineTo(new Vector3f(xxx, yyy, zzz)); lineTo(new Vector3f(xxx, yyy, zzz));
} }
public void lineTo(final Vector2f dest) { public void lineTo(final Vector2f dest) {
lineTo(new Vector3f(dest.x(), dest.y(), 0)); lineTo(new Vector3f(dest.x(), dest.y(), 0));
} }
/** /**
* draw a line to a specific position * draw a line to a specific position
* @param dest Position of the end of the line. * @param dest Position of the end of the line.
@ -341,14 +364,14 @@ public abstract class CompositingDrawing extends CompositingDraw {
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z())); setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z()));
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z())); setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z()));
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, this.position.z())); setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, this.position.z()));
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, dest.z())); setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, dest.z()));
setPoint(new Vector3f(dest.x() - offsetx, dest.y() - offsety, dest.z())); setPoint(new Vector3f(dest.x() - offsetx, dest.y() - offsety, dest.z()));
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z())); setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z()));
// update the system position : // update the system position :
this.position = dest; this.position = dest;
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
@ -367,19 +390,19 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
} }
} }
public void rectangle(final float xxx, final float yyy) { public void rectangle(final float xxx, final float yyy) {
rectangle(new Vector3f(xxx, yyy, 0)); rectangle(new Vector3f(xxx, yyy, 0));
} }
public void rectangle(final float xxx, final float yyy, final float zzz) { public void rectangle(final float xxx, final float yyy, final float zzz) {
rectangle(new Vector3f(xxx, yyy, zzz)); rectangle(new Vector3f(xxx, yyy, zzz));
} }
public void rectangle(final Vector2f dest) { public void rectangle(final Vector2f dest) {
rectangle(dest.toVector3f()); rectangle(dest.toVector3f());
} }
/** /**
* draw a 2D rectangle to the position requested. * draw a 2D rectangle to the position requested.
* @param dest Position the the end of the rectangle * @param dest Position the the end of the rectangle
@ -388,7 +411,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
internalSetColor(this.color); internalSetColor(this.color);
rectangleRaw(this.position, dest); rectangleRaw(this.position, dest);
} }
public void rectangleRaw(final Vector3f startPos, final Vector3f endPos) { public void rectangleRaw(final Vector3f startPos, final Vector3f endPos) {
resetCount(); resetCount();
/* /*
@ -434,16 +457,16 @@ public abstract class CompositingDrawing extends CompositingDraw {
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxA, dyC, 0)); setPoint(new Vector3f(dxA, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
} }
public void rectangleBorder(final Vector2f dest, final float borderWidth) { public void rectangleBorder(final Vector2f dest, final float borderWidth) {
rectangleBorder(dest.toVector3f(), borderWidth); rectangleBorder(dest.toVector3f(), borderWidth);
} }
public void rectangleBorder(final Vector3f dest, final float borderWidth) { public void rectangleBorder(final Vector3f dest, final float borderWidth) {
/* /*
* Bitmap position xA xB * Bitmap position xA xB
@ -519,39 +542,39 @@ public abstract class CompositingDrawing extends CompositingDraw {
setPoint(new Vector3f(dxA, dyC, 0)); setPoint(new Vector3f(dxA, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxpA, dypC, 0)); setPoint(new Vector3f(dxpA, dypC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxpA, dypC, 0)); setPoint(new Vector3f(dxpA, dypC, 0));
setPoint(new Vector3f(dxpB, dypC, 0)); setPoint(new Vector3f(dxpB, dypC, 0));
// Right border: // Right border:
setPoint(new Vector3f(dxpB, dypC, 0)); setPoint(new Vector3f(dxpB, dypC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxpB, dypC, 0)); setPoint(new Vector3f(dxpB, dypC, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxpB, dypD, 0)); setPoint(new Vector3f(dxpB, dypD, 0));
// Top border: // Top border:
setPoint(new Vector3f(dxpB, dypD, 0)); setPoint(new Vector3f(dxpB, dypD, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxpB, dypD, 0)); setPoint(new Vector3f(dxpB, dypD, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxpA, dypD, 0)); setPoint(new Vector3f(dxpA, dypD, 0));
// Left border: // Left border:
setPoint(new Vector3f(dxpA, dypD, 0)); setPoint(new Vector3f(dxpA, dypD, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxpA, dypC, 0)); setPoint(new Vector3f(dxpA, dypC, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxpA, dypC, 0)); setPoint(new Vector3f(dxpA, dypC, 0));
setPoint(new Vector3f(dxA, dyC, 0)); setPoint(new Vector3f(dxA, dyC, 0));
} }
/** /**
* draw a 2D rectangle to the position requested. * draw a 2D rectangle to the position requested.
* @param dest Position the the end of the rectangle * @param dest Position the the end of the rectangle
@ -559,11 +582,11 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void rectangleRadius(final Vector2f dest, final float radius) { public void rectangleRadius(final Vector2f dest, final float radius) {
rectangleRadius(dest.toVector3f(), radius); rectangleRadius(dest.toVector3f(), radius);
} }
public void rectangleRadius(final Vector3f dest, final float radius) { public void rectangleRadius(final Vector3f dest, final float radius) {
internalSetColor(this.color); internalSetColor(this.color);
final boolean showConstruct = false; final boolean showConstruct = true;
rectangleRaw(this.position.add(new Vector3f(radius, 0, 0)), dest.less(new Vector3f(radius, 0, 0))); rectangleRaw(this.position.add(new Vector3f(radius, 0, 0)), dest.less(new Vector3f(radius, 0, 0)));
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.ORANGE); internalSetColor(Color.ORANGE);
@ -575,7 +598,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
} }
rectangleRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0), rectangleRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0),
new Vector3f(dest.x(), dest.y() - radius, 0)); new Vector3f(dest.x(), dest.y() - radius, 0));
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.AQUA_MARINE); internalSetColor(Color.AQUA_MARINE);
} }
@ -585,7 +608,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
FMath.PI * 0.5f); FMath.PI * 0.5f);
circleRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, FMath.PI * 0.5f, circleRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, FMath.PI * 0.5f,
FMath.PI * 0.5f); FMath.PI * 0.5f);
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.BLACK); internalSetColor(Color.BLACK);
rectangleRaw(this.position, this.position.add(10)); rectangleRaw(this.position, this.position.add(10));
@ -593,14 +616,56 @@ public abstract class CompositingDrawing extends CompositingDraw {
rectangleRaw(dest.less(10), dest); rectangleRaw(dest.less(10), dest);
} }
} }
public void rectangleRadius(final Vector2f dest, final Insets thickness, final BorderRadius radius) {
internalSetColor(this.color);
final boolean showConstruct = true;
// center rectangle
rectangleRaw(this.position.add(new Vector3f(thickness.top(), thickness.top(), 0)),
dest.toVector3f().less(new Vector3f(thickness.top(), thickness.top(), 0)));
// top & bottom rectangle ==> refacto ..
// rectangleRaw(this.position.add(new Vector3f(thickness.top(), 0, 0)),
// dest.toVector3f().less(new Vector3f(radius.topLeft(), 0, 0)));
// if (showConstruct) {
// internalSetColor(Color.ORANGE);
// }
// // left rectangle
// rectangleRaw(this.position.add(new Vector3f(0, radius.topLeft(), 0)),
// new Vector3f(this.position.x() + radius.topLeft(), dest.y() - radius.topLeft(), 0));
// if (showConstruct) {
// internalSetColor(Color.GRAY);
// }
// // right rectangle
// rectangleRaw(new Vector3f(dest.x() - radius.topLeft(), this.position.y() + radius.topLeft(), 0),
// new Vector3f(dest.x(), dest.y() - radius.topLeft(), 0));
if (showConstruct) {
internalSetColor(Color.AQUA_MARINE);
}
circleRaw(this.position.add(radius.topLeft(), radius.topLeft(), 0), radius.topLeft(), FMath.PI,
FMath.PI * 0.5f);
circleRaw(dest.toVector3f().less(radius.topLeft(), radius.topLeft(), 0), radius.topLeft(), 0, FMath.PI * 0.5f);
circleRaw(new Vector3f(dest.x() - radius.topLeft(), this.position.y() + radius.topLeft(), 0), radius.topLeft(),
FMath.PI * 1.5f, FMath.PI * 0.5f);
circleRaw(new Vector3f(this.position.x() + radius.topLeft(), dest.y() - radius.topLeft(), 0), radius.topLeft(),
FMath.PI * 0.5f, FMath.PI * 0.5f);
if (showConstruct) {
internalSetColor(Color.BLACK);
rectangleRaw(this.position, this.position.add(10));
internalSetColor(Color.RED);
rectangleRaw(dest.toVector3f().less(10), dest.toVector3f());
}
}
public void rectangleBorderRadius(final Vector2f dest, final float thickness, final float radius) { public void rectangleBorderRadius(final Vector2f dest, final float thickness, final float radius) {
rectangleBorderRadius(dest.toVector3f(), thickness, radius); rectangleBorderRadius(dest.toVector3f(), thickness, radius);
} }
public void rectangleBorderRadius(final Vector3f dest, final float thickness, final float radius) { public void rectangleBorderRadius(final Vector3f dest, final float thickness, final float radius) {
internalSetColor(this.color); internalSetColor(this.colorBg);
final boolean showConstruct = true; final boolean showConstruct = false;
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.ANTIQUE_WHITE); internalSetColor(Color.ANTIQUE_WHITE);
} }
@ -616,7 +681,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
// right // right
rectangleRaw(new Vector3f(dest.x() - thickness * 0.5f, this.position.y() + radius, 0), rectangleRaw(new Vector3f(dest.x() - thickness * 0.5f, this.position.y() + radius, 0),
new Vector3f(dest.x() + thickness * 0.5f, dest.y() - radius, 0)); new Vector3f(dest.x() + thickness * 0.5f, dest.y() - radius, 0));
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.DARK_RED); internalSetColor(Color.DARK_RED);
} }
@ -626,7 +691,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
FMath.PI * 1.5f, FMath.PI * 0.5f); FMath.PI * 1.5f, FMath.PI * 0.5f);
circleBorderRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, thickness, circleBorderRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, thickness,
FMath.PI * 0.5f, FMath.PI * 0.5f); FMath.PI * 0.5f, FMath.PI * 0.5f);
if (showConstruct) { if (showConstruct) {
internalSetColor(Color.BLACK); internalSetColor(Color.BLACK);
rectangleRaw(this.position, this.position.add(10)); rectangleRaw(this.position, this.position.add(10));
@ -635,18 +700,59 @@ public abstract class CompositingDrawing extends CompositingDraw {
} }
} }
public void rectangleBorderRadius(
//final Vector2f pos,
final Vector2f dest,
final Insets thickness,
final BorderRadius radius) {
internalSetColor(this.color);
final boolean showConstruct = true;
if (showConstruct) {
internalSetColor(Color.ANTIQUE_WHITE);
}
// // Bottom
// rectangleRaw(new Vector3f(this.position.x() + radius, this.position.y() - thickness * 0.5f, 0),
// new Vector3f(dest.x() - radius, this.position.y() + thickness * 0.5f, 0));
// // top
// rectangleRaw(new Vector3f(this.position.x() + radius, dest.y() - thickness * 0.5f, 0),
// new Vector3f(dest.x() - radius, dest.y() + thickness * 0.5f, 0));
// // left
// rectangleRaw(new Vector3f(this.position.x() - thickness * 0.5f, this.position.y() + radius, 0),
// new Vector3f(this.position.x() + thickness * 0.5f, dest.y() - radius, 0));
// // right
// rectangleRaw(new Vector3f(dest.x() - thickness * 0.5f, this.position.y() + radius, 0),
// new Vector3f(dest.x() + thickness * 0.5f, dest.y() - radius, 0));
//
// if (showConstruct) {
// internalSetColor(Color.DARK_RED);
// }
// circleBorderRaw(this.position.add(radius, radius, 0), radius, thickness, FMath.PI, FMath.PI * 0.5f);
// circleBorderRaw(dest.less(radius, radius, 0), radius, thickness, 0, FMath.PI * 0.5f);
// circleBorderRaw(new Vector3f(dest.x() - radius, this.position.y() + radius, 0), radius, thickness,
// FMath.PI * 1.5f, FMath.PI * 0.5f);
// circleBorderRaw(new Vector3f(this.position.x() + radius, dest.y() - radius, 0), radius, thickness,
// FMath.PI * 0.5f, FMath.PI * 0.5f);
//
// if (showConstruct) {
// internalSetColor(Color.BLACK);
// rectangleRaw(this.position, this.position.add(10));
// internalSetColor(Color.RED);
// rectangleRaw(dest.less(10), dest);
// }
}
public void rectangleWidth(final float xxx, final float yyy) { public void rectangleWidth(final float xxx, final float yyy) {
rectangleWidth(new Vector3f(xxx, yyy, 0)); rectangleWidth(new Vector3f(xxx, yyy, 0));
} }
public void rectangleWidth(final float xxx, final float yyy, final float zzz) { public void rectangleWidth(final float xxx, final float yyy, final float zzz) {
rectangleWidth(new Vector3f(xxx, yyy, zzz)); rectangleWidth(new Vector3f(xxx, yyy, zzz));
} }
public void rectangleWidth(final Vector2f size) { public void rectangleWidth(final Vector2f size) {
rectangleWidth(new Vector3f(size.x(), size.y(), 0)); rectangleWidth(new Vector3f(size.x(), size.y(), 0));
} }
/** /**
* draw a 2D rectangle to the requested size. * draw a 2D rectangle to the requested size.
* @param size size of the rectangle * @param size size of the rectangle
@ -654,18 +760,18 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void rectangleWidth(final Vector3f size) { public void rectangleWidth(final Vector3f size) {
rectangle(this.position.add(size)); rectangle(this.position.add(size));
} }
/** /**
* in case of some error the count can be reset * in case of some error the count can be reset
*/ */
private void resetCount() { private void resetCount() {
this.triElement = 0; this.triElement = 0;
} }
public void setClipping(final Vector2f pos, final Vector2f posEnd) { public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1)); setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -678,7 +784,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.clippingPosStart = Vector3f.min(pos, posEnd); this.clippingPosStart = Vector3f.min(pos, posEnd);
this.clippingEnable = true; this.clippingEnable = true;
} }
/** /**
* enable/Disable the clipping (without lose the current clipping * enable/Disable the clipping (without lose the current clipping
* position) * position)
@ -687,11 +793,11 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setClippingMode(final boolean newMode) { public void setClippingMode(final boolean newMode) {
this.clippingEnable = newMode; this.clippingEnable = newMode;
} }
public void setClippingWidth(final Vector2f pos, final Vector2f width) { public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2)); setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -700,7 +806,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setClippingWidth(final Vector3f pos, final Vector3f width) { public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @param color Color to set on foreground (for next print)
@ -708,7 +814,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setColor(final Color color) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
/** /**
* set the background color of the font (for selected Text (not the * set the background color of the font (for selected Text (not the
* global BG)) * global BG))
@ -717,7 +823,7 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setColorBg(final Color color) { public void setColorBg(final Color color) {
this.colorBg = color; this.colorBg = color;
} }
/** /**
* internal add of the specific point * internal add of the specific point
* @param point The requeste dpoint to add * @param point The requeste dpoint to add
@ -730,19 +836,19 @@ public abstract class CompositingDrawing extends CompositingDraw {
} }
this.vbo.flush(); this.vbo.flush();
} }
public void setPos(final float xxx, final float yyy) { public void setPos(final float xxx, final float yyy) {
setPos(new Vector3f(xxx, yyy, 0)); setPos(new Vector3f(xxx, yyy, 0));
} }
public void setPos(final float xxx, final float yyy, final float zzz) { public void setPos(final float xxx, final float yyy, final float zzz) {
setPos(new Vector3f(xxx, yyy, zzz)); setPos(new Vector3f(xxx, yyy, zzz));
} }
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text written * set position for the next text written
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -750,11 +856,11 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
this.position = pos; this.position = pos;
} }
public void setRelPos(final float xxx, final float yyy) { public void setRelPos(final float xxx, final float yyy) {
this.position = this.position.add(xxx, yyy, 0); this.position = this.position.add(xxx, yyy, 0);
} }
/** /**
* set relative position for the next text writen * set relative position for the next text writen
* @param pos ofset apply of the text (in 3D) * @param pos ofset apply of the text (in 3D)
@ -762,15 +868,15 @@ public abstract class CompositingDrawing extends CompositingDraw {
public void setRelPos(final float xxx, final float yyy, final float zzz) { public void setRelPos(final float xxx, final float yyy, final float zzz) {
this.position = this.position.add(xxx, yyy, zzz); this.position = this.position.add(xxx, yyy, zzz);
} }
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
public void setRelPos(final Vector3f pos) { public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos); this.position = this.position.add(pos);
} }
/** /**
* Specify the line thickness for the next elements * Specify the line thickness for the next elements
* @param thickness The thickness desired for the next print * @param thickness The thickness desired for the next print
@ -782,12 +888,12 @@ public abstract class CompositingDrawing extends CompositingDraw {
this.thickness *= -1; this.thickness *= -1;
} }
} }
/** /**
* Un-Load the openGL program and get all the ID needed * Un-Load the openGL program and get all the ID needed
*/ */
private void unLoadProgram() { private void unLoadProgram() {
this.oGLprogram = null; this.oGLprogram = null;
} }
} }

View File

@ -5,7 +5,9 @@
*/ */
package org.atriasoft.ewol.compositing; package org.atriasoft.ewol.compositing;
import org.atriasoft.etk.BorderRadius;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Insets;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -58,6 +60,24 @@ public class CompositingGC extends CompositingDrawing {
} }
} }
@Override
public void addRectangle(
final Vector2f position,
final Vector2f size,
final Insets thickness,
final BorderRadius radius) {
if (radius == null || radius.isZero()) {
//addRectangle(position, size);
//throw new RuntimeException("Not implemented ...");
} else {
setPos(position);
rectangleRadius(position.add(size), thickness, radius);
if (this.strokeSize > 0) {
rectangleBorderRadius(position.add(size), thickness, radius);
}
}
}
@Override @Override
public void addCircle(final Vector2f position, final float radius) { public void addCircle(final Vector2f position, final float radius) {
setPos(position); setPos(position);

View File

@ -16,7 +16,9 @@ import org.atriasoft.esvg.JoinMode;
import org.atriasoft.esvg.Line; import org.atriasoft.esvg.Line;
import org.atriasoft.esvg.PaintState; import org.atriasoft.esvg.PaintState;
import org.atriasoft.esvg.Rectangle; import org.atriasoft.esvg.Rectangle;
import org.atriasoft.etk.BorderRadius;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Insets;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
@ -49,20 +51,20 @@ public class CompositingSVG extends CompositingDraw {
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
private Vector3f position = Vector3f.ZERO; //!< The current position to draw private Vector3f position = Vector3f.ZERO; //!< The current position to draw
private Vector2i requestSize = new Vector2i(2, 2); private Vector2i requestSize = new Vector2i(2, 2);
private ResourceTexture2 resource = null; //!< texture resources private ResourceTexture2 resource = null; //!< texture resources
private ResourceVirtualArrayObject vbo = null; private ResourceVirtualArrayObject vbo = null;
private Color[] vboDataColors = null; private Color[] vboDataColors = null;
private Vector3f[] vboDataCoords = null; private Vector3f[] vboDataCoords = null;
private Vector2f[] vboDataCoordsTex = null; private Vector2f[] vboDataCoordsTex = null;
public CompositingSVG() { public CompositingSVG() {
this(""" this("""
<svg width="10" height="10"></svg> <svg width="10" height="10"></svg>
""", CompositingSVG.SIZE_AUTO); """, CompositingSVG.SIZE_AUTO);
} }
public CompositingSVG(final String data, final int size) { public CompositingSVG(final String data, final int size) {
this.svgData = data; this.svgData = data;
// Create the VBO: // Create the VBO:
@ -76,7 +78,7 @@ public class CompositingSVG extends CompositingDraw {
setSource(this.svgData, size); setSource(this.svgData, size);
loadProgram(); loadProgram();
} }
/** /**
* clear alll tre registered element in the current element * clear alll tre registered element in the current element
*/ */
@ -91,7 +93,7 @@ public class CompositingSVG extends CompositingDraw {
this.color = Color.WHITE; this.color = Color.WHITE;
this.angle = 0; this.angle = 0;
} }
/** /**
* draw All the registered text in the current element on openGL * draw All the registered text in the current element on openGL
* @param disableDepthTest disable the Depth test for display * @param disableDepthTest disable the Depth test for display
@ -131,7 +133,7 @@ public class CompositingSVG extends CompositingDraw {
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void flush() { public void flush() {
generate(); generate();
@ -143,7 +145,7 @@ public class CompositingSVG extends CompositingDraw {
this.vbo.flush(); this.vbo.flush();
} }
} }
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -151,7 +153,7 @@ public class CompositingSVG extends CompositingDraw {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
/** /**
* get the source image registered size in the file (<0 when multiple size image) * get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size * @return tre image registered size
@ -162,7 +164,7 @@ public class CompositingSVG extends CompositingDraw {
} }
return this.resource.getUsableSize(); return this.resource.getUsableSize();
} }
/** /**
* Sometimes the user declare an image but not allocate the resources all the time, this is to know it .. * Sometimes the user declare an image but not allocate the resources all the time, this is to know it ..
* @return the validity of the resources. * @return the validity of the resources.
@ -170,7 +172,7 @@ public class CompositingSVG extends CompositingDraw {
public boolean hasSources() { public boolean hasSources() {
return this.resource != null; return this.resource != null;
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
@ -184,11 +186,11 @@ public class CompositingSVG extends CompositingDraw {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
} }
} }
public void print(final Vector2f size) { public void print(final Vector2f size) {
printPart(size, Vector2f.ZERO, Vector2f.ONE); printPart(size, Vector2f.ZERO, Vector2f.ONE);
} }
/** /**
* add a compleate of the image to display with the requested size * add a compleate of the image to display with the requested size
* @param size size of the output image * @param size size of the output image
@ -196,7 +198,7 @@ public class CompositingSVG extends CompositingDraw {
public void print(final Vector2i size) { public void print(final Vector2i size) {
print(new Vector2f(size.x(), size.y())); print(new Vector2f(size.x(), size.y()));
} }
/** /**
* add a part of the image to display with the requested size * add a part of the image to display with the requested size
* @param size size of the output image * @param size size of the output image
@ -214,73 +216,73 @@ public class CompositingSVG extends CompositingDraw {
final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio); final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio);
LOGGER.trace(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart LOGGER.trace(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart
+ " stop=" + sourcePosStop); + " stop=" + sourcePosStop);
this.vboDataColors = new Color[6]; this.vboDataColors = new Color[6];
this.vboDataCoords = new Vector3f[6]; this.vboDataCoords = new Vector3f[6];
this.vboDataCoordsTex = new Vector2f[6]; this.vboDataCoordsTex = new Vector2f[6];
if (this.angle == 0.0f) { if (this.angle == 0.0f) {
Vector3f point = this.position; Vector3f point = this.position;
int indexElem = 0; int indexElem = 0;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0); point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0); point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0); point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(this.position.x(), this.position.y(), 0); point = new Vector3f(this.position.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
return; return;
} }
final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f); final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f);
final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f); final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f);
Vector3f point = Vector3f.ZERO; Vector3f point = Vector3f.ZERO;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
int indexElem = 0; int indexElem = 0;
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -288,7 +290,7 @@ public class CompositingSVG extends CompositingDraw {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0); point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -296,12 +298,12 @@ public class CompositingSVG extends CompositingDraw {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -309,16 +311,16 @@ public class CompositingSVG extends CompositingDraw {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
} }
/** /**
* set a unique rotation of this element (not set in the rotate Generic system) * set a unique rotation of this element (not set in the rotate Generic system)
* @param angleRad Angle to set in radiant. * @param angleRad Angle to set in radiant.
@ -326,7 +328,7 @@ public class CompositingSVG extends CompositingDraw {
public void setAngle(final float angleRad) { public void setAngle(final float angleRad) {
this.angle = angleRad; this.angle = angleRad;
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @param color Color to set on foreground (for next print)
@ -334,15 +336,15 @@ public class CompositingSVG extends CompositingDraw {
public void setColor(final Color color) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
public void setPos(final Vector2i pos) { public void setPos(final Vector2i pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text written * set position for the next text written
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -350,11 +352,11 @@ public class CompositingSVG extends CompositingDraw {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
this.position = pos; this.position = pos;
} }
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set relative position for the next text written * set relative position for the next text written
* @param pos offset apply of the text (in 3D) * @param pos offset apply of the text (in 3D)
@ -362,7 +364,7 @@ public class CompositingSVG extends CompositingDraw {
public void setRelPos(final Vector3f pos) { public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos); this.position = this.position.add(pos);
} }
public void setSource(final ImageByteRGBA image) { public void setSource(final ImageByteRGBA image) {
clear(); clear();
this.svgData = null; this.svgData = null;
@ -370,20 +372,20 @@ public class CompositingSVG extends CompositingDraw {
this.resource = new ResourceTexture2(); this.resource = new ResourceTexture2();
this.resource.set(image); this.resource.set(image);
} }
public void setSource(final String data) { public void setSource(final String data) {
setSource(data, 32); setSource(data, 32);
} }
public void setSource(final String data, final int size) { public void setSource(final String data, final int size) {
setSource(data, new Vector2i(size, size)); setSource(data, new Vector2i(size, size));
} }
// public void setSource(final Uri data, final Vector2i size) { // public void setSource(final Uri data, final Vector2i size) {
// data // data
// setSource // setSource
// } // }
public void setSource(final String data, final Vector2i size) { public void setSource(final String data, final Vector2i size) {
if (data == null) { if (data == null) {
LOGGER.error("try to set NULL data in svg"); LOGGER.error("try to set NULL data in svg");
@ -411,7 +413,7 @@ public class CompositingSVG extends CompositingDraw {
this.svgData = data; this.svgData = data;
this.requestSize = size; this.requestSize = size;
} }
public void setSource(final EsvgDocument data, final Vector2i size) { public void setSource(final EsvgDocument data, final Vector2i size) {
if (this.svgData == null && this.svgDoc.equals(data) && this.requestSize.x() == size.x() if (this.svgData == null && this.svgDoc.equals(data) && this.requestSize.x() == size.x()
&& this.requestSize.y() == size.y()) { && this.requestSize.y() == size.y()) {
@ -423,7 +425,7 @@ public class CompositingSVG extends CompositingDraw {
this.requestSize = size; this.requestSize = size;
generate(); generate();
} }
protected void generate() { protected void generate() {
final Vector2i size = this.requestSize; final Vector2i size = this.requestSize;
if (this.svgDoc != null) { if (this.svgDoc != null) {
@ -438,13 +440,13 @@ public class CompositingSVG extends CompositingDraw {
this.resource.set(tmp); this.resource.set(tmp);
} }
} }
PaintState paint = new PaintState();
PaintState paint = new PaintState();
public void clearPaint() { public void clearPaint() {
this.paint.clear(); this.paint.clear();
} }
public void createSize(final Vector2i size) { public void createSize(final Vector2i size) {
clear(); clear();
this.paint.clear(); this.paint.clear();
@ -453,38 +455,38 @@ public class CompositingSVG extends CompositingDraw {
} }
this.requestSize = size; this.requestSize = size;
} }
@Override @Override
public void setPaintFillColor(final Color color) { public void setPaintFillColor(final Color color) {
this.paint.fill = new Pair<>(color, ""); this.paint.fill = new Pair<>(color, "");
} }
@Override @Override
public void setPaintStrokeColor(final Color color) { public void setPaintStrokeColor(final Color color) {
this.paint.stroke = new Pair<>(color, ""); this.paint.stroke = new Pair<>(color, "");
} }
@Override @Override
public void setPaintStrokeWidth(final float width) { public void setPaintStrokeWidth(final float width) {
this.paint.strokeWidth = width; this.paint.strokeWidth = width;
} }
public void setPaintLineJoin(final JoinMode lineJoin) { public void setPaintLineJoin(final JoinMode lineJoin) {
this.paint.lineJoin = lineJoin; this.paint.lineJoin = lineJoin;
} }
public void setPaintLineCap(final CapMode lineCap) { public void setPaintLineCap(final CapMode lineCap) {
this.paint.lineCap = lineCap; this.paint.lineCap = lineCap;
} }
public void setPaintMiterLimit(final float miterLimit) { public void setPaintMiterLimit(final float miterLimit) {
this.paint.miterLimit = miterLimit; this.paint.miterLimit = miterLimit;
} }
public void setPaintOpacity(final float opacity) { public void setPaintOpacity(final float opacity) {
this.paint.opacity = opacity; this.paint.opacity = opacity;
} }
@Override @Override
public void addLine(final Vector2f startPos, final Vector2f stopPos) { public void addLine(final Vector2f startPos, final Vector2f stopPos) {
if (this.svgDoc == null) { if (this.svgDoc == null) {
@ -492,7 +494,7 @@ public class CompositingSVG extends CompositingDraw {
} }
this.svgDoc.addElement(new Line(startPos, stopPos, this.paint)); this.svgDoc.addElement(new Line(startPos, stopPos, this.paint));
} }
@Override @Override
public void addRectangle(final Vector2f position, final Vector2f size) { public void addRectangle(final Vector2f position, final Vector2f size) {
if (this.svgDoc == null) { if (this.svgDoc == null) {
@ -500,7 +502,7 @@ public class CompositingSVG extends CompositingDraw {
} }
this.svgDoc.addElement(new Rectangle(position, size, this.paint)); this.svgDoc.addElement(new Rectangle(position, size, this.paint));
} }
@Override @Override
public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) { public void addRectangle(final Vector2f position, final Vector2f size, final Vector2f roundedCorner) {
if (this.svgDoc == null) { if (this.svgDoc == null) {
@ -508,7 +510,7 @@ public class CompositingSVG extends CompositingDraw {
} }
this.svgDoc.addElement(new Rectangle(position, size, roundedCorner, this.paint)); this.svgDoc.addElement(new Rectangle(position, size, roundedCorner, this.paint));
} }
@Override @Override
public void addCircle(final Vector2f position, final float radius) { public void addCircle(final Vector2f position, final float radius) {
if (this.svgDoc == null) { if (this.svgDoc == null) {
@ -516,7 +518,7 @@ public class CompositingSVG extends CompositingDraw {
} }
this.svgDoc.addElement(new Circle(position, radius, this.paint)); this.svgDoc.addElement(new Circle(position, radius, this.paint));
} }
@Override @Override
public void addEllipse(final Vector2f center, final Vector2f radius) { public void addEllipse(final Vector2f center, final Vector2f radius) {
if (this.svgDoc == null) { if (this.svgDoc == null) {
@ -524,14 +526,14 @@ public class CompositingSVG extends CompositingDraw {
} }
this.svgDoc.addElement(new Ellipse(center, radius, this.paint)); this.svgDoc.addElement(new Ellipse(center, radius, this.paint));
} }
public void setRectangleAsSource(final int sizeX, final int sizeY, final Color color) { public void setRectangleAsSource(final int sizeX, final int sizeY, final Color color) {
createSize(new Vector2i(sizeX, sizeY)); // specific for SVG createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
setPaintFillColor(color); setPaintFillColor(color);
addRectangle(Vector2f.ZERO, new Vector2f(sizeX, sizeY)); addRectangle(Vector2f.ZERO, new Vector2f(sizeX, sizeY));
flush(); flush();
} }
public void setRectangleBorderAsSource( public void setRectangleBorderAsSource(
final int sizeX, final int sizeX,
final int sizeY, final int sizeY,
@ -539,7 +541,7 @@ public class CompositingSVG extends CompositingDraw {
final int borderSize, final int borderSize,
final int borderRadius, final int borderRadius,
final Color borderColor) { final Color borderColor) {
final int paddingCompensateBorder = Math.round(borderSize * 0.5f); final int paddingCompensateBorder = Math.round(borderSize * 0.5f);
createSize(new Vector2i(sizeX, sizeY)); // specific for SVG createSize(new Vector2i(sizeX, sizeY)); // specific for SVG
setPaintFillColor(color); setPaintFillColor(color);
@ -550,4 +552,14 @@ public class CompositingSVG extends CompositingDraw {
new Vector2f(borderRadius, borderRadius)); new Vector2f(borderRadius, borderRadius));
flush(); flush();
} }
@Override
public void addRectangle(
final Vector2f position,
final Vector2f size,
final Insets thickness,
final BorderRadius radius) {
// TODO Auto-generated method stub
}
} }

View File

@ -5,8 +5,10 @@ import org.atriasoft.aknot.annotation.AknotDescription;
import org.atriasoft.aknot.annotation.AknotManaged; import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.aknot.annotation.AknotName; import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.DimensionBorderRadius;
import org.atriasoft.etk.DimensionInsets;
import org.atriasoft.etk.Insets;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.compositing.CompositingGC; import org.atriasoft.ewol.compositing.CompositingGC;
@ -17,7 +19,7 @@ import org.slf4j.LoggerFactory;
public class Box extends Container { public class Box extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Box.class); private static final Logger LOGGER = LoggerFactory.getLogger(Box.class);
protected CompositingGC vectorialDraw = new CompositingGC(); protected CompositingGC vectorialDraw = new CompositingGC();
public static class BoxParameter { public static class BoxParameter {
public Float margin; public Float margin;
public Float padding; public Float padding;
@ -26,7 +28,7 @@ public class Box extends Container {
public String borderColor; public String borderColor;
public String color; public String color;
} }
/** /**
* Periodic call to update grapgic display * Periodic call to update grapgic display
* @param event Time generic event * @param event Time generic event
@ -35,40 +37,40 @@ public class Box extends Container {
LOGGER.trace("Periodic call on Entry(" + event + ")"); LOGGER.trace("Periodic call on Entry(" + event + ")");
self.markToRedraw(); self.markToRedraw();
} }
Vector2i startPosition = Vector2i.ZERO; Vector2i startPosition = Vector2i.ZERO;
Vector2i endPosition = Vector2i.ZERO; Vector2i endPosition = Vector2i.ZERO;
public boolean isInside(final Vector2f value) { public boolean isInside(final Vector2f value) {
return value.x() > this.startPosition.x() // return value.x() > this.startPosition.x() //
&& value.y() > this.startPosition.y() // && value.y() > this.startPosition.y() //
&& value.x() < this.endPosition.x() // && value.x() < this.endPosition.x() //
&& value.y() < this.endPosition.y(); && value.y() < this.endPosition.y();
} }
/** /**
* Constructor * Constructor
*/ */
public Box() {} public Box() {}
/** /**
* Constructor with his subWidget * Constructor with his subWidget
*/ */
public Box(final Widget subWidget) { public Box(final Widget subWidget) {
super(subWidget); super(subWidget);
} }
protected Dimension1f propertyBorderWidth = Dimension1f.ZERO;
protected DimensionInsets propertyBorderWidth = DimensionInsets.ZERO;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "border-width") @AknotName(value = "border-width")
@AknotDescription(value = "Border of the box") @AknotDescription(value = "Border of the box")
public Dimension1f getPropertyBorderWidth() { public DimensionInsets getPropertyBorderWidth() {
return this.propertyBorderWidth; return this.propertyBorderWidth;
} }
public void setPropertyBorderWidth(final Dimension1f propertyBorder) { public void setPropertyBorderWidth(final DimensionInsets propertyBorder) {
if (this.propertyBorderWidth.equals(propertyBorder)) { if (this.propertyBorderWidth.equals(propertyBorder)) {
return; return;
} }
@ -76,18 +78,18 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
protected Dimension1f propertyBorderRadius = new Dimension1f(0); protected DimensionBorderRadius propertyBorderRadius = DimensionBorderRadius.ZERO;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "border-radius") @AknotName(value = "border-radius")
@AknotDescription(value = "Border radius of the box") @AknotDescription(value = "Border radius of the box")
public Dimension1f getPropertyBorderRadius() { public DimensionBorderRadius getPropertyBorderRadius() {
return this.propertyBorderRadius; return this.propertyBorderRadius;
} }
public void setPropertyBorderRadius(final Dimension1f propertyBorderRadius) { public void setPropertyBorderRadius(final DimensionBorderRadius propertyBorderRadius) {
if (this.propertyBorderRadius.equals(propertyBorderRadius)) { if (this.propertyBorderRadius.equals(propertyBorderRadius)) {
return; return;
} }
@ -95,9 +97,9 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
protected Color propertyBorderColor = Color.NONE;
protected Color propertyBorderColor = Color.NONE;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "border-color") @AknotName(value = "border-color")
@ -105,7 +107,7 @@ public class Box extends Container {
public Color getPropertyBorderColor() { public Color getPropertyBorderColor() {
return this.propertyBorderColor; return this.propertyBorderColor;
} }
public void setPropertyBorderColor(final Color propertyBorderColor) { public void setPropertyBorderColor(final Color propertyBorderColor) {
if (this.propertyBorderColor.equals(propertyBorderColor)) { if (this.propertyBorderColor.equals(propertyBorderColor)) {
return; return;
@ -114,9 +116,9 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
protected Color propertyColor = Color.NONE; protected Color propertyColor = Color.NONE;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "color") @AknotName(value = "color")
@ -124,7 +126,7 @@ public class Box extends Container {
public Color getPropertyColor() { public Color getPropertyColor() {
return this.propertyColor; return this.propertyColor;
} }
public void setPropertyColor(final Color propertyColor) { public void setPropertyColor(final Color propertyColor) {
if (this.propertyColor.equals(propertyColor)) { if (this.propertyColor.equals(propertyColor)) {
return; return;
@ -133,9 +135,9 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
protected Dimension2f propertyMargin = Dimension2f.ZERO;
protected Dimension2f propertyMargin = Dimension2f.ZERO;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "margin") @AknotName(value = "margin")
@ -143,7 +145,7 @@ public class Box extends Container {
public Dimension2f getPropertyMargin() { public Dimension2f getPropertyMargin() {
return this.propertyMargin; return this.propertyMargin;
} }
public void setPropertyMargin(final Dimension2f propertyMargin) { public void setPropertyMargin(final Dimension2f propertyMargin) {
if (this.propertyMargin.equals(propertyMargin)) { if (this.propertyMargin.equals(propertyMargin)) {
return; return;
@ -152,9 +154,9 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
protected Dimension2f propertyPadding = Dimension2f.ZERO;
protected Dimension2f propertyPadding = Dimension2f.ZERO;
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "padding") @AknotName(value = "padding")
@ -162,7 +164,7 @@ public class Box extends Container {
public Dimension2f getPropertyPadding() { public Dimension2f getPropertyPadding() {
return this.propertyPadding; return this.propertyPadding;
} }
public void setPropertyPadding(final Dimension2f propertyPadding) { public void setPropertyPadding(final Dimension2f propertyPadding) {
if (this.propertyPadding.equals(propertyPadding)) { if (this.propertyPadding.equals(propertyPadding)) {
return; return;
@ -171,24 +173,25 @@ public class Box extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
super.calculateMinMaxSize(); super.calculateMinMaxSize();
final Vector2f childMinSize = new Vector2f(this.minSize.x(), this.minSize.y()); final Vector2f childMinSize = new Vector2f(this.minSize.x(), this.minSize.y());
LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth); LOGGER.debug("calculate min size: border=" + this.propertyBorderWidth);
final Vector2f borderSize = new Vector2f(this.propertyBorderWidth.size() * 2.0f, final Insets borderSize = this.propertyBorderWidth.getPixel();
this.propertyBorderWidth.size() * 2.0f);
final Vector2f padding = this.propertyPadding.size().multiply(2); final Vector2f padding = this.propertyPadding.size().multiply(2);
final Vector2f margin = this.propertyMargin.size().multiply(2); final Vector2f margin = this.propertyMargin.size().multiply(2);
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize);
final Vector2f calculatedBoxMinSize = childMinSize.add(margin).add(padding).add(borderSize.toVector2f());
this.minSize = calculatedBoxMinSize; this.minSize = calculatedBoxMinSize;
this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size()); this.maxSize = Vector2f.max(this.minSize, this.propertyMaxSize.size());
markToRedraw(); markToRedraw();
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
markToRedraw(); markToRedraw();
@ -200,9 +203,9 @@ public class Box extends Container {
} }
final Vector2f localPadding = this.propertyPadding.size(); final Vector2f localPadding = this.propertyPadding.size();
final Vector2f localMargin = this.propertyMargin.size(); final Vector2f localMargin = this.propertyMargin.size();
final float localBorderSize = this.propertyBorderWidth.size(); final Insets localBorderSize = this.propertyBorderWidth.getPixel();
final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize); final Vector2f offsetSubWidget = localPadding.add(localMargin).add(localBorderSize.toVector2f());
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize(); Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
if (this.subWidget.canExpand().x() && this.propertyFill.x()) { if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
subWidgetSize = subWidgetSize.withX(this.size.x()); subWidgetSize = subWidgetSize.withX(this.size.x());
@ -216,7 +219,7 @@ public class Box extends Container {
} }
subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2)); subWidgetSize = subWidgetSize.less(offsetSubWidget.multiply(2));
subWidgetSize = subWidgetSize.clipInteger(); subWidgetSize = subWidgetSize.clipInteger();
final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize); final Vector2f freeSizeWithoutWidget = this.size.less(offsetSubWidget.multiply(2)).less(subWidgetSize);
Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget)); Vector2f subWidgetOrigin = this.origin.add(this.propertyGravity.gravityGenerateDelta(freeSizeWithoutWidget));
subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget); subWidgetOrigin = subWidgetOrigin.add(offsetSubWidget);
@ -225,11 +228,11 @@ public class Box extends Container {
this.subWidget.setSize(subWidgetSize); this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
} }
private Vector2f calculateOriginRendering(final Vector2f renderSize) { private Vector2f calculateOriginRendering(final Vector2f renderSize) {
return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize)); return this.propertyGravity.gravityGenerateDelta(this.size.less(renderSize));
} }
private Vector2f calculateSizeRendering() { private Vector2f calculateSizeRendering() {
Vector2f tmpRenderSize = this.minSize; Vector2f tmpRenderSize = this.minSize;
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
@ -240,7 +243,7 @@ public class Box extends Container {
} }
return tmpRenderSize; return tmpRenderSize;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
super.onRegenerateDisplay(); super.onRegenerateDisplay();
@ -248,33 +251,32 @@ public class Box extends Container {
//return; //return;
} }
final Vector2f localMargin = this.propertyMargin.size(); final Vector2f localMargin = this.propertyMargin.size();
Vector2f renderSize = calculateSizeRendering(); Vector2f renderSize = calculateSizeRendering();
Vector2f renderOrigin = calculateOriginRendering(renderSize); Vector2f renderOrigin = calculateOriginRendering(renderSize);
renderOrigin = renderOrigin.add(localMargin); renderOrigin = renderOrigin.add(localMargin);
renderSize = renderSize.less(localMargin.multiply(2)); renderSize = renderSize.less(localMargin.multiply(2));
// not sure this is needed... // not sure this is needed...
renderSize = renderSize.clipInteger(); renderSize = renderSize.clipInteger();
renderOrigin = renderOrigin.clipInteger(); renderOrigin = renderOrigin.clipInteger();
renderOrigin = renderOrigin.clipInteger(); renderOrigin = renderOrigin.clipInteger();
renderSize = renderSize.clipInteger(); renderSize = renderSize.clipInteger();
this.startPosition = renderOrigin.toVector2i(); this.startPosition = renderOrigin.toVector2i();
this.endPosition = renderSize.toVector2i(); this.endPosition = renderSize.toVector2i();
//System.out.println("renderSize: " + this.renderSize); //System.out.println("renderSize: " + this.renderSize);
// remove data of the previous composition : // remove data of the previous composition :
this.vectorialDraw.clear(); this.vectorialDraw.clear();
final int borderSize = (int) this.propertyBorderWidth.size();
this.vectorialDraw.setPaintFillColor(this.propertyColor); this.vectorialDraw.setPaintFillColor(this.propertyColor);
this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor); this.vectorialDraw.setPaintStrokeColor(this.propertyBorderColor);
this.vectorialDraw.setPaintStrokeWidth(borderSize); //this.vectorialDraw.setPaintStrokeWidth(borderSize);
this.vectorialDraw.addRectangle(renderOrigin, renderSize, this.vectorialDraw.addRectangle(renderOrigin, renderSize, this.propertyBorderWidth.getPixel(),
new Vector2f(this.propertyBorderRadius.size(), this.propertyBorderRadius.size())); this.propertyBorderRadius.getPixel());
this.vectorialDraw.flush(); this.vectorialDraw.flush();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.vectorialDraw != null) { if (this.vectorialDraw != null) {
@ -282,5 +284,5 @@ public class Box extends Container {
} }
super.onDraw(); super.onDraw();
} }
} }

View File

@ -8,8 +8,8 @@ import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.esignal.Connection; import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.SignalEmpty; import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.DimensionInsets;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class Button extends Box { public class Button extends Box {
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class); private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
public static Button createLabelButton(final String label) { public static Button createLabelButton(final String label) {
final Button out = new Button(); final Button out = new Button();
final Label labelWidget = new Label(); final Label labelWidget = new Label();
@ -46,7 +46,7 @@ public class Button extends Box {
out.setSubWidget(labelWidget); out.setSubWidget(labelWidget);
return out; return out;
} }
/** /**
* Periodic call to update graphic display * Periodic call to update graphic display
* @param event Time generic event * @param event Time generic event
@ -58,12 +58,12 @@ public class Button extends Box {
// } // }
self.markToRedraw(); self.markToRedraw();
} }
/// Periodic call handle to remove it when needed /// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection(); protected Connection periodicConnectionHanble = new Connection();
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol"); private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
@AknotSignal @AknotSignal
@AknotName(value = "down") @AknotName(value = "down")
@AknotDescription("Button is Down") @AknotDescription("Button is Down")
@ -84,10 +84,10 @@ public class Button extends Box {
@AknotName(value = "leave") @AknotName(value = "leave")
@AknotDescription("The cursor leave the button") @AknotDescription("The cursor leave the button")
public SignalEmpty signalLeave = new SignalEmpty(); public SignalEmpty signalLeave = new SignalEmpty();
private boolean buttonPressed = false; private boolean buttonPressed = false;
private final boolean mouseHover = false; private final boolean mouseHover = false;
/** /**
* Constructor * Constructor
*/ */
@ -98,15 +98,15 @@ public class Button extends Box {
setMouseLimit(1); setMouseLimit(1);
setPropertyExpand(Vector2b.TRUE); setPropertyExpand(Vector2b.TRUE);
setPropertyFill(Vector2b.TRUE); setPropertyFill(Vector2b.TRUE);
setPropertyBorderWidth(new Dimension1f(4)); setPropertyBorderWidth(new DimensionInsets(4));
//setPropertyBorderRadius(new Dimension1f(15)); //setPropertyBorderRadius(new Dimension1f(15));
setPropertyBorderColor(Color.BLACK); setPropertyBorderColor(Color.BLACK);
setPropertyColor(Color.WHITE); setPropertyColor(Color.WHITE);
setPropertyPadding(new Dimension2f(new Vector2f(3, 3))); setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
setPropertyMargin(new Dimension2f(new Vector2f(0, 0))); setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "config") @AknotName(value = "config")
@ -114,7 +114,7 @@ public class Button extends Box {
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
@Override @Override
protected boolean onEventEntry(final EventEntry event) { protected boolean onEventEntry(final EventEntry event) {
//LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
@ -124,7 +124,7 @@ public class Button extends Box {
} }
return super.onEventEntry(event); return super.onEventEntry(event);
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector2f relPos = relativePosition(event.pos()); final Vector2f relPos = relativePosition(event.pos());
@ -184,14 +184,14 @@ public class Button extends Box {
} }
return false; return false;
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
this.buttonPressed = false; this.buttonPressed = false;
LOGGER.trace(this.name + " : Remove Focus ..."); LOGGER.trace(this.name + " : Remove Focus ...");
//checkStatus(); //checkStatus();
} }
public void setPropertyConfig(final Uri propertyConfig) { public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) { if (this.propertyConfig.equals(propertyConfig)) {
return; return;

View File

@ -9,8 +9,8 @@ import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.Signal; import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty; import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Dimension1f;
import org.atriasoft.etk.Dimension2f; import org.atriasoft.etk.Dimension2f;
import org.atriasoft.etk.DimensionInsets;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2b; import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
@ -45,19 +45,19 @@ public Uri> propertyShape; //!< shape of the widget
public class Tick extends Box { public class Tick extends Box {
private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class); private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class);
protected CompositingSVG compositingTick = new CompositingSVG(); protected CompositingSVG compositingTick = new CompositingSVG();
/// color property of the text foreground /// color property of the text foreground
private int colorIdTextFg; private int colorIdTextFg;
/// text display this.text /// text display this.text
//private final CompositingGraphicContext gc = new CompositingGraphicContext(); //private final CompositingGraphicContext gc = new CompositingGraphicContext();
/// Periodic call handle to remove it when needed /// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection(); protected Connection periodicConnectionHanble = new Connection();
private final Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol"); private final Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol");
private final Uri uriCheckGreen = new Uri("THEME", "CheckBoxCrossRed.svg", "ewol"); private final Uri uriCheckGreen = new Uri("THEME", "CheckBoxCrossRed.svg", "ewol");
private Boolean propertyValue = false; //!< string that must be displayed
private Boolean propertyValue = false; //!< string that must be displayed
@AknotSignal @AknotSignal
@AknotName("down") @AknotName("down")
@AknotDescription("Tick is Down") @AknotDescription("Tick is Down")
@ -77,9 +77,9 @@ public class Tick extends Box {
// element over: // element over:
Vector2f overPositionStart = Vector2f.ZERO; Vector2f overPositionStart = Vector2f.ZERO;
Vector2f overPositionStop = Vector2f.ZERO; Vector2f overPositionStop = Vector2f.ZERO;
private boolean isDown; private boolean isDown;
/** /**
* Constuctor * Constuctor
*/ */
@ -91,15 +91,15 @@ public class Tick extends Box {
setPropertyExpand(Vector2b.FALSE); setPropertyExpand(Vector2b.FALSE);
setPropertyFill(Vector2b.TRUE); setPropertyFill(Vector2b.TRUE);
setPropertyMinSize(new Dimension2f(new Vector2f(32f, 32f))); setPropertyMinSize(new Dimension2f(new Vector2f(32f, 32f)));
setPropertyBorderWidth(new Dimension1f(4)); setPropertyBorderWidth(new DimensionInsets(4));
//setPropertyBorderRadius(new Dimension1f(15)); //setPropertyBorderRadius(new Dimension1f(15));
setPropertyBorderColor(Color.BLACK); setPropertyBorderColor(Color.BLACK);
setPropertyColor(Color.WHITE); setPropertyColor(Color.WHITE);
setPropertyPadding(new Dimension2f(new Vector2f(3, 3))); setPropertyPadding(new Dimension2f(new Vector2f(3, 3)));
setPropertyMargin(new Dimension2f(new Vector2f(0, 0))); setPropertyMargin(new Dimension2f(new Vector2f(0, 0)));
}
}
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -107,7 +107,7 @@ public class Tick extends Box {
// get generic padding // get generic padding
final Padding padding = Padding.ZERO; final Padding padding = Padding.ZERO;
final Vector2i minHeight = Vector2i.VALUE_16; final Vector2i minHeight = Vector2i.VALUE_16;
Vector2f minimumSizeBase = new Vector2f(minHeight.x(), minHeight.y()); Vector2f minimumSizeBase = new Vector2f(minHeight.x(), minHeight.y());
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y());
@ -116,7 +116,7 @@ public class Tick extends Box {
checkMinSize(); checkMinSize();
LOGGER.error("min size = " + this.minSize); LOGGER.error("min size = " + this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
// if (this.shape.changeStatusIn(newStatusId)) { // if (this.shape.changeStatusIn(newStatusId)) {
// if (!this.periodicConnectionHanble.isConnected()) { // if (!this.periodicConnectionHanble.isConnected()) {
@ -127,12 +127,12 @@ public class Tick extends Box {
// markToRedraw(); // markToRedraw();
// } // }
} }
private boolean checkIfOver(final Vector2f relPos) { private boolean checkIfOver(final Vector2f relPos) {
return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -140,16 +140,16 @@ public class Tick extends Box {
public Boolean getPropertyValue() { public Boolean getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
protected void onChangePropertyTextWhenNothing() { protected void onChangePropertyTextWhenNothing() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
//Boolean newData = this.propertyValue; //Boolean newData = this.propertyValue;
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
super.onDraw(); super.onDraw();
@ -162,7 +162,7 @@ public class Tick extends Box {
// this.shape.draw(true, this.propertyValue ? 0 : 1); // this.shape.draw(true, this.propertyValue ? 0 : 1);
// } // }
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector2f positionAbsolute = new Vector2f(event.pos().x(), event.pos().y()); final Vector2f positionAbsolute = new Vector2f(event.pos().x(), event.pos().y());
@ -224,7 +224,7 @@ public class Tick extends Box {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
super.onRegenerateDisplay(); super.onRegenerateDisplay();
@ -236,7 +236,7 @@ public class Tick extends Box {
this.compositingTick.print(this.startPosition.less(4).toVector2f()); this.compositingTick.print(this.startPosition.less(4).toVector2f());
this.compositingTick.flush(); this.compositingTick.flush();
} }
/** /**
* internal check the value with RegExp checking * internal check the value with RegExp checking
* @param newData The new string to display * @param newData The new string to display
@ -245,7 +245,7 @@ public class Tick extends Box {
this.propertyValue = newData; this.propertyValue = newData;
markToRedraw(); markToRedraw();
} }
public void setPropertyValue(final Boolean propertyValue) { public void setPropertyValue(final Boolean propertyValue) {
if (this.propertyValue.equals(propertyValue)) { if (this.propertyValue.equals(propertyValue)) {
return; return;
@ -254,5 +254,5 @@ public class Tick extends Box {
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
onChangePropertyValue(); onChangePropertyValue();
} }
} }