mirror of
https://github.com/macocianradu/javaGUItoolkit.git
synced 2026-03-18 21:50:04 +00:00
added hardware acceleration support
refactored to work with jdk 8 changed the validator to reentrant lock
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class BottomCenterPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public BottomCenterPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int y = parentSize.y - size.y - margin.b;
|
||||
int x = (parentSize.x - size.x) / 2;
|
||||
return new Point2<>(x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class BottomLeftPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public BottomLeftPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int y = parentSize.y - size.y - margin.b;
|
||||
return new Point2<>(margin.b, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class BottomRightPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public BottomRightPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int y = parentSize.y - size.y - margin.b;
|
||||
int x = parentSize.x - size.x - margin.d;
|
||||
return new Point2<>(x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class GeneralPlacer implements Placer {
|
||||
private Point2<Integer> location;
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point2<Float> relativeLocation;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public GeneralPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
relativeLocation = new Point2<>(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
location = new Point2<>(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
int x = location.x;
|
||||
int y = location.y;
|
||||
if(parentSize != null) {
|
||||
if(relativeLocation != null) {
|
||||
if(relativeLocation.x != -1) {
|
||||
x = Math.round(relativeLocation.x * parentSize.x);
|
||||
}
|
||||
if(relativeLocation.y != -1) {
|
||||
y = Math.round(relativeLocation.y * parentSize.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Point2<>(x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class MiddleCenterPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public MiddleCenterPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int x = (parentSize.x - size.x) / 2;
|
||||
int y = (parentSize.y - size.y) / 2;
|
||||
return new Point2<>(x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class MiddleLeftPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public MiddleLeftPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int y = (parentSize.y - size.y) / 2;
|
||||
return new Point2<>(margin.c, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class MiddleRightPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public MiddleRightPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int x = parentSize.x - size.x - margin.d;
|
||||
int y = (parentSize.y - size.y) / 2;
|
||||
return new Point2<>(x, y);
|
||||
}
|
||||
}
|
||||
15
src/guiTree/Components/Decorations/Placers/Placer.java
Normal file
15
src/guiTree/Components/Decorations/Placers/Placer.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public interface Placer {
|
||||
void setRelativeLocation(float x, float y);
|
||||
void setLocation(int x, int y);
|
||||
void setElementSize(int width, int height);
|
||||
void setParentSize(int width, int height);
|
||||
void setMargins(int up, int down, int left, int right);
|
||||
void setMargins(int margin);
|
||||
Point4<Integer> getMargins();
|
||||
Point2<Integer> getPosition();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class TopCenterPlacer implements Placer{
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public TopCenterPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int x = (parentSize.x - size.x) / 2;
|
||||
return new Point2<>(x, margin.a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class TopLeftPlacer implements Placer {
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public TopLeftPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float relativeX, float relativeY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package guiTree.Components.Decorations.Placers;
|
||||
|
||||
import guiTree.Helper.Point2;
|
||||
import guiTree.Helper.Point4;
|
||||
|
||||
public class TopRightPlacer implements Placer {
|
||||
private Point2<Integer> size;
|
||||
private Point2<Integer> parentSize;
|
||||
private Point4<Integer> margin;
|
||||
|
||||
public TopRightPlacer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
if(parentSize == null) {
|
||||
return new Point2<>(margin.c, margin.a);
|
||||
}
|
||||
int x = parentSize.x - size.x - margin.d;
|
||||
return new Point2<>(x, margin.a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user