mirror of
https://github.com/macocianradu/javaGUItoolkit.git
synced 2026-03-18 13:40:04 +00:00
changed lock
changed placer to abstract class
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
Name="Window"
|
||||
Visible="True"
|
||||
Title="Sudoku 1.0"
|
||||
EnableGPU="True"
|
||||
HardwareAccelerated="True"
|
||||
Size="1024, 576">
|
||||
<GridPanel
|
||||
BackgroundColor="#75ff75"
|
||||
@@ -19,7 +17,7 @@
|
||||
<Panel
|
||||
BackgroundColor="#555555"
|
||||
Name="Panel"
|
||||
Overlapping="false"
|
||||
Overlapping="true"
|
||||
Row="0"
|
||||
Column="1">
|
||||
<Picture
|
||||
@@ -28,6 +26,7 @@
|
||||
Name="Image"
|
||||
Image="heart"/>
|
||||
<RadioButtons
|
||||
Name="Radio Buttons"
|
||||
Size="0.4f, 0.3f">
|
||||
<RadioButton
|
||||
Text="Iubesc"
|
||||
@@ -53,6 +52,7 @@
|
||||
BackgroundColor="#999999"
|
||||
AccentColor="#aaaaaa"
|
||||
ForegroundColor="#ffffff"
|
||||
Name="Input Text Box"
|
||||
Location="0.0f, 0.8f"
|
||||
Size="300, 60">
|
||||
</InputTextBox>>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import guiTree.Components.Button;
|
||||
import guiTree.Components.Panel;
|
||||
import guiTree.Components.Picture;
|
||||
import guiTree.Window;
|
||||
import guiTree.events.MouseAdapter;
|
||||
@@ -25,6 +26,7 @@ public class Main {
|
||||
Button bottomCenter = (Button) window.findByName("bottomCenter");
|
||||
Button bottomRight = (Button) window.findByName("bottomRight");
|
||||
Picture picture = (Picture) window.findByName("Image");
|
||||
Panel panel = (Panel) window.findByName("Panel");
|
||||
|
||||
topLeft.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -1,55 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class BottomCenterPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,55 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class BottomLeftPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,55 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class BottomRightPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -3,57 +3,7 @@ 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;
|
||||
}
|
||||
public class GeneralPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,55 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class MiddleCenterPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,56 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class MiddleLeftPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,56 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class MiddleRightPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -3,13 +3,58 @@ 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();
|
||||
public abstract class Placer {
|
||||
Point2<Integer> location;
|
||||
Point2<Integer> size;
|
||||
Point2<Integer> parentSize;
|
||||
Point2<Float> relativeLocation;
|
||||
Point4<Integer> margin;
|
||||
|
||||
public Placer() {
|
||||
margin = new Point4<>(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public void setRelativeLocation(float x, float y) {
|
||||
relativeLocation = new Point2<>(x, y);
|
||||
}
|
||||
|
||||
public void setLocation(int x, int y) {
|
||||
location = new Point2<>(x, y);
|
||||
}
|
||||
|
||||
public Point2<Integer> getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Point2<Float> getRelativeLocation() {
|
||||
return relativeLocation;
|
||||
}
|
||||
|
||||
public void setElementSize(int width, int height) {
|
||||
size = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
public void setParentSize(int width, int height) {
|
||||
parentSize = new Point2<>(width, height);
|
||||
}
|
||||
|
||||
public void setMargins(int up, int down, int left, int right) {
|
||||
margin.a = up;
|
||||
margin.b = down;
|
||||
margin.c = left;
|
||||
margin.d = right;
|
||||
}
|
||||
|
||||
public void setMargins(int margin) {
|
||||
this.margin.a = margin;
|
||||
this.margin.b = margin;
|
||||
this.margin.c = margin;
|
||||
this.margin.d = margin;
|
||||
}
|
||||
|
||||
public Point4<Integer> getMargins() {
|
||||
return margin;
|
||||
}
|
||||
|
||||
abstract public Point2<Integer> getPosition();
|
||||
}
|
||||
|
||||
@@ -1,56 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class TopCenterPlacer extends Placer{
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,52 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class TopLeftPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -1,55 +1,8 @@
|
||||
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;
|
||||
}
|
||||
public class TopRightPlacer extends Placer {
|
||||
|
||||
@Override
|
||||
public Point2<Integer> getPosition() {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class Visual {
|
||||
@@ -72,7 +71,7 @@ public class Visual {
|
||||
private static Visual entered;
|
||||
private static Visual focused;
|
||||
private Boolean pressed;
|
||||
private Lock validating;
|
||||
private static ReentrantLock validating = new ReentrantLock();
|
||||
private Boolean hardwareAccelerated;
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
@@ -114,7 +113,6 @@ public class Visual {
|
||||
absoluteX = 0;
|
||||
absoluteY = 0;
|
||||
|
||||
validating = new ReentrantLock();
|
||||
hardwareAccelerated = useGPU;
|
||||
}
|
||||
|
||||
@@ -210,6 +208,16 @@ public class Visual {
|
||||
setLocation();
|
||||
}
|
||||
|
||||
public void setLocationX(Float x) {
|
||||
locationPlacer.setRelativeLocation(x, getRelativeLocation().y);
|
||||
setLocation();
|
||||
}
|
||||
|
||||
public void setLocationY(Float y) {
|
||||
locationPlacer.setRelativeLocation(getRelativeLocation().x, y);
|
||||
setLocation();
|
||||
}
|
||||
|
||||
public void setLocationX(Integer x) {
|
||||
setLocation(x, getLocationY());
|
||||
}
|
||||
@@ -287,6 +295,7 @@ public class Visual {
|
||||
try {
|
||||
this.font = Font.createFont(Font.TRUETYPE_FONT, new File("resources\\fonts\\" + font + ".ttf"));
|
||||
this.font = this.font.deriveFont(style, size);
|
||||
update();
|
||||
} catch (FontFormatException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -371,6 +380,8 @@ public class Visual {
|
||||
return new Point2<>(locationX, locationY);
|
||||
}
|
||||
|
||||
public Point2<Float> getRelativeLocation() {return locationPlacer.getRelativeLocation();}
|
||||
|
||||
public int getAbsoluteX() {
|
||||
return absoluteX;
|
||||
}
|
||||
@@ -518,7 +529,12 @@ public class Visual {
|
||||
}
|
||||
}
|
||||
if(dirty && active) {
|
||||
revalidate();
|
||||
validating.lock();
|
||||
try {
|
||||
revalidate();
|
||||
} finally {
|
||||
validating.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,25 +542,21 @@ public class Visual {
|
||||
Debugger.log("Revalidating " + name, Debugger.Tag.PAINTING);
|
||||
Timer timer = new Timer();
|
||||
|
||||
validating.lock();
|
||||
try {
|
||||
timer.startTiming();
|
||||
timer.startTiming();
|
||||
|
||||
clearImageBuffer();
|
||||
paint(imageBuffer);
|
||||
for (Visual v : children) {
|
||||
if (v.dirty && v.active) {
|
||||
v.revalidate();
|
||||
}
|
||||
Graphics2D g = (Graphics2D) imageBuffer.getGraphics();
|
||||
g.drawImage(v.imageBuffer, v.locationX, v.locationY, null);
|
||||
g.dispose();
|
||||
clearImageBuffer();
|
||||
paint(imageBuffer);
|
||||
for (Visual v : children) {
|
||||
if (v.dirty && v.active) {
|
||||
v.revalidate();
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
} finally {
|
||||
validating.unlock();
|
||||
Graphics2D g = (Graphics2D) imageBuffer.getGraphics();
|
||||
g.drawImage(v.imageBuffer, v.locationX, v.locationY, null);
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
|
||||
if(!(this instanceof Window)){
|
||||
long time = timer.stopTiming();
|
||||
Debugger.log("Finished Revalidating " + name + ": " + time, Debugger.Tag.PAINTING);
|
||||
@@ -632,7 +644,6 @@ public class Visual {
|
||||
}
|
||||
focused = entered;
|
||||
Debugger.log("Pressed " + entered.name, Debugger.Tag.LISTENER);
|
||||
System.out.println(entered.name + " hardware accelerated: " + imageBuffer.getCapabilities(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).isAccelerated());
|
||||
}
|
||||
|
||||
void mouseEntered(MouseEvent mouseEvent) {
|
||||
@@ -824,19 +835,14 @@ public class Visual {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
validating.lock();
|
||||
try {
|
||||
if(!dirty) {
|
||||
validating.lock();
|
||||
dirty = true;
|
||||
} finally {
|
||||
validating.unlock();
|
||||
}
|
||||
|
||||
if(parent != null) {
|
||||
parent.validating.lock();
|
||||
try {
|
||||
parent.update();
|
||||
} finally {
|
||||
parent.validating.unlock();
|
||||
}
|
||||
parent.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ public class Window extends Visual implements Runnable{
|
||||
|
||||
public void setMainPanel(Panel panel) {
|
||||
this.removeVisual(mainPanel);
|
||||
mainPanel.setOverlapping(true);
|
||||
contentPanel = new Panel();
|
||||
contentPanel.setName("ContentPanel");
|
||||
if(titleBar != null) {
|
||||
|
||||
Reference in New Issue
Block a user