mirror of
https://github.com/macocianradu/javaGUItoolkit.git
synced 2026-03-18 13:40:04 +00:00
removed recursive call in paint
added scroll panes without relative position
This commit is contained in:
@@ -4,63 +4,11 @@
|
|||||||
Visible="true"
|
Visible="true"
|
||||||
Size="640, 480"
|
Size="640, 480"
|
||||||
Title="FANTASTICEST UI THINGY">
|
Title="FANTASTICEST UI THINGY">
|
||||||
<!-- <Panel-->
|
<ScrollPanel Name="ScrollPane" BackgroundColor="#333333" Size="1.0, 1.0" Location="0.0, 0.0">
|
||||||
<!-- Name="ProgramPanel"-->
|
<ToggleButton Name="button3" BackgroundColor="#123456" AccentColor="#654321" Size="100, 100" Location="320, 240" Icon="minimize_white"/>
|
||||||
<!-- Size="1.0, 1.0"-->
|
<Slider Name="Slider" Size="100, 20" Location="0, 0" Direction="horizontal" SliderSize="0.3"/>
|
||||||
<!-- Location="0.0, 0.0"-->
|
<Slider Name="VSlider" Size="20, 100" Location="101, 0" SliderSize="0.5"/>
|
||||||
<!-- BackgroundColor="#333333">-->
|
<Button Name="Button" BackgroundColor="#777777" AccentColor="#654321" Size="100, 100" Location="660, 0"/>
|
||||||
<Button
|
<Button Name="Button" BackgroundColor="#777777" AccentColor="#654321" Size="100, 100" Location="660, 660"/>
|
||||||
Name="button1"
|
</ScrollPanel>
|
||||||
BackgroundColor="#999999"
|
|
||||||
AccentColor="#666666"
|
|
||||||
ForegroundColor="#333333"
|
|
||||||
Size="320, 240"
|
|
||||||
Location="0.0, 0.5"
|
|
||||||
HasBorder="true"
|
|
||||||
Label="button1">
|
|
||||||
<Button
|
|
||||||
Name="button4"
|
|
||||||
BackgroundColor="#009999"
|
|
||||||
AccentColor="#006666"
|
|
||||||
ForegroundColor="#003333"
|
|
||||||
Size="0.5, 0.5"
|
|
||||||
Location="0.25, 0.25"
|
|
||||||
Icon="square_white"
|
|
||||||
HasBorder="true">
|
|
||||||
<ToggleButton
|
|
||||||
Name="button2"
|
|
||||||
BackgroundColor="#000099"
|
|
||||||
AccentColor="#000066"
|
|
||||||
ForegroundColor="#000033"
|
|
||||||
Size="0.5, 0.5"
|
|
||||||
Location="0.25, 0.25"
|
|
||||||
Label="button2"/>
|
|
||||||
</Button>
|
|
||||||
</Button>
|
|
||||||
<!-- <Button Name="button6" BackgroundColor="#555555" Location="0.5, 0.5" Size="0.5, 0.5"/>-->
|
|
||||||
<!-- <CheckBoxList-->
|
|
||||||
<!-- Name="checkboxlist"-->
|
|
||||||
<!-- CheckBoxSize="300, 20"-->
|
|
||||||
<!-- BackgroundColor="#666666"-->
|
|
||||||
<!-- AccentColor="#444444"-->
|
|
||||||
<!-- ForegroundColor="#005599"-->
|
|
||||||
<!-- Size="0.5, 0.3"-->
|
|
||||||
<!-- Icon="check_white"-->
|
|
||||||
<!-- Spacing="30"-->
|
|
||||||
<!-- Location="0.0, 0.0">-->
|
|
||||||
<!-- <CheckBox-->
|
|
||||||
<!-- Name="checkbox1"-->
|
|
||||||
<!-- Text="HAHA FRAR"/>-->
|
|
||||||
<!-- <CheckBox-->
|
|
||||||
<!-- Name="checkbox2"-->
|
|
||||||
<!-- Text="HAHA FRAR2"/>-->
|
|
||||||
<!-- <CheckBox-->
|
|
||||||
<!-- Name="checkbox3"-->
|
|
||||||
<!-- Text="HAHA FRAR3"/>-->
|
|
||||||
<!-- </CheckBoxList>-->
|
|
||||||
<ToggleButton Name="button3" BackgroundColor="#123456" AccentColor="654321" Size="100, 100" Location="0.5, 0.5" Icon="minimize_white"/>
|
|
||||||
<Slider Name="slider" Location="-20, 0" Size="20, 100" HasBorder="false"/>
|
|
||||||
<Slider Name="hslider" Location="400, 0" Size="80, 20" Direction="horizontal"/>
|
|
||||||
<Button Location="350, 20" Size="20, 70"/>
|
|
||||||
<!-- </Panel>-->
|
|
||||||
</Window>
|
</Window>
|
||||||
@@ -1,53 +1,14 @@
|
|||||||
import guiTree.Animations.ColorAnimation;
|
import guiTree.Components.ScrollPanel;
|
||||||
import guiTree.Animations.LocationAnimation;
|
|
||||||
import guiTree.Components.Slider;
|
|
||||||
import guiTree.Helper.Point2;
|
|
||||||
import guiTree.Visual;
|
|
||||||
import guiTree.Window;
|
import guiTree.Window;
|
||||||
import guiTree.events.MouseAdapter;
|
|
||||||
import parser.XAMLParser;
|
import parser.XAMLParser;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try{
|
try{
|
||||||
Window window = XAMLParser.parse("ui.xml");
|
Window window = XAMLParser.parse("ui.xml");
|
||||||
assert window != null;
|
assert window != null;
|
||||||
Slider hslider = (Slider)window.findByName("hslider");
|
ScrollPanel scrollPanel = (ScrollPanel)window.findByName("ScrollPane");
|
||||||
Slider slider = (Slider)window.findByName("slider");
|
System.out.println();
|
||||||
window.repaint();
|
|
||||||
ColorAnimation sliderColor = new ColorAnimation(hslider, slider.getBackgroundColor(), Color.RED, 1000);
|
|
||||||
window.addMouseListener(new MouseAdapter() {
|
|
||||||
private boolean out = false;
|
|
||||||
private LocationAnimation outAnimation;
|
|
||||||
private LocationAnimation inAnimation;
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent mouseEvent) {
|
|
||||||
if(mouseEvent.getX() < 20 && mouseEvent.getY() > 0 && mouseEvent.getY() < 100) {
|
|
||||||
if(!out) {
|
|
||||||
outAnimation = new LocationAnimation(slider, slider.getLocation(), new Point2<>(0, slider.getLocationY()), 500);
|
|
||||||
window.removeAnimation(inAnimation);
|
|
||||||
window.addAnimation(outAnimation);
|
|
||||||
out = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(out) {
|
|
||||||
inAnimation = new LocationAnimation(slider, slider.getLocation(), new Point2<>(- 20, slider.getLocationY()), 500);
|
|
||||||
window.removeAnimation(outAnimation);
|
|
||||||
window.addAnimation(inAnimation);
|
|
||||||
out = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Thread.sleep(5000);
|
|
||||||
System.out.println("Started moving");
|
|
||||||
hslider.addAnimation(new LocationAnimation(hslider, hslider.getLocation(), new Point2<>(hslider.getLocationX(), hslider.getLocationY() + 100), 1000));
|
|
||||||
hslider.addAnimation(sliderColor);
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class FloatConverter implements ConverterInterface<Float> {
|
|||||||
public Float convert(String content) throws InvalidTypeException {
|
public Float convert(String content) throws InvalidTypeException {
|
||||||
content = content.replaceAll(" ", "");
|
content = content.replaceAll(" ", "");
|
||||||
float number = Float.parseFloat(content);
|
float number = Float.parseFloat(content);
|
||||||
if(number > 1 || number < 0) {
|
if(number > 1 || number < 0 || !content.contains(".")) {
|
||||||
throw new InvalidTypeException();
|
throw new InvalidTypeException();
|
||||||
}
|
}
|
||||||
return Float.parseFloat(content);
|
return Float.parseFloat(content);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class ColorAnimation implements AnimationInterface {
|
|||||||
from.b > to.b - 1 && from.b < to.b + 1 &&
|
from.b > to.b - 1 && from.b < to.b + 1 &&
|
||||||
from.c > to.c - 1 && from.c < to.c + 1 &&
|
from.c > to.c - 1 && from.c < to.c + 1 &&
|
||||||
from.d > to.d - 1 && from.d < to.d + 1) {
|
from.d > to.d - 1 && from.d < to.d + 1) {
|
||||||
element.setBackgroundColor(new Color(to.a, to.b, to.c, to.d));
|
element.setPaintColor(new Color(to.a, to.b, to.c, to.d));
|
||||||
Debugger.log("Animation for " + element.getName() + " finished", Debugger.Tag.ANIMATIONS);
|
Debugger.log("Animation for " + element.getName() + " finished", Debugger.Tag.ANIMATIONS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class ColorAnimation implements AnimationInterface {
|
|||||||
from.b += offset.b;
|
from.b += offset.b;
|
||||||
from.c += offset.c;
|
from.c += offset.c;
|
||||||
from.d += offset.d;
|
from.d += offset.d;
|
||||||
element.setBackgroundColor(new Color(Math.round(from.a), Math.round(from.b), Math.round(from.c), Math.round(from.d)));
|
element.setPaintColor(new Color(Math.round(from.a), Math.round(from.b), Math.round(from.c), Math.round(from.d)));
|
||||||
element.update();
|
element.update();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package guiTree.Components;
|
package guiTree.Components;
|
||||||
|
|
||||||
|
import guiTree.Animations.ColorAnimation;
|
||||||
import guiTree.Helper.Debugger;
|
import guiTree.Helper.Debugger;
|
||||||
import guiTree.Visual;
|
import guiTree.Visual;
|
||||||
import guiTree.events.MouseAdapter;
|
import guiTree.events.MouseAdapter;
|
||||||
@@ -13,8 +14,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Button extends Visual {
|
public class Button extends Visual {
|
||||||
private String label;
|
private String label;
|
||||||
private Boolean pressed;
|
|
||||||
private Boolean hovered;
|
|
||||||
private BufferedImage icon;
|
private BufferedImage icon;
|
||||||
private int round = -1;
|
private int round = -1;
|
||||||
|
|
||||||
@@ -34,36 +33,33 @@ public class Button extends Visual {
|
|||||||
super();
|
super();
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
pressed = false;
|
|
||||||
hovered = false;
|
|
||||||
this.addMouseListener(new MouseAdapter() {
|
this.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent mouseEvent) {
|
public void mouseClicked(MouseEvent mouseEvent) {
|
||||||
pressed = false;
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent mouseEvent) {
|
public void mousePressed(MouseEvent mouseEvent) {
|
||||||
pressed = true;
|
addAnimation(new ColorAnimation(Button.this, getAccentColor(), getForegroundColor(), 100));
|
||||||
update();
|
update();
|
||||||
Debugger.log("Pressed: " + getName(), Debugger.Tag.LISTENER);
|
Debugger.log("Pressed: " + getName(), Debugger.Tag.LISTENER);
|
||||||
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent mouseEvent) {
|
public void mouseReleased(MouseEvent mouseEvent) {
|
||||||
pressed = false;
|
addAnimation(new ColorAnimation(Button.this, getForegroundColor(), getAccentColor(), 100));
|
||||||
update();
|
update();
|
||||||
Debugger.log("Calling repaint from released: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from released: " + getName(), Debugger.Tag.PAINTING);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent mouseEvent) {
|
public void mouseEntered(MouseEvent mouseEvent) {
|
||||||
hovered = true;
|
addAnimation(new ColorAnimation(Button.this, getBackgroundColor(), getAccentColor(), 100));
|
||||||
update();
|
update();
|
||||||
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent mouseEvent) {
|
public void mouseExited(MouseEvent mouseEvent) {
|
||||||
hovered = false;
|
addAnimation(new ColorAnimation(Button.this, getAccentColor(), getBackgroundColor(), 100));
|
||||||
update();
|
update();
|
||||||
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
||||||
}
|
}
|
||||||
@@ -83,17 +79,7 @@ public class Button extends Visual {
|
|||||||
//Get Graphics
|
//Get Graphics
|
||||||
Graphics2D g = imageBuffer.createGraphics();
|
Graphics2D g = imageBuffer.createGraphics();
|
||||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g.setColor(getPaintColor());
|
||||||
//Choose background
|
|
||||||
if(hovered) {
|
|
||||||
g.setColor(this.getAccentColor());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g.setColor(this.getBackgroundColor());
|
|
||||||
}
|
|
||||||
if(pressed) {
|
|
||||||
g.setColor(this.getForegroundColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw Button
|
//Draw Button
|
||||||
if(getHasBorder()) {
|
if(getHasBorder()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package guiTree.Components;
|
package guiTree.Components;
|
||||||
|
|
||||||
|
import guiTree.Animations.ColorAnimation;
|
||||||
import guiTree.Helper.Debugger;
|
import guiTree.Helper.Debugger;
|
||||||
import guiTree.Visual;
|
import guiTree.Visual;
|
||||||
import guiTree.events.MouseAdapter;
|
import guiTree.events.MouseAdapter;
|
||||||
@@ -37,19 +38,29 @@ public class CheckBox extends Visual {
|
|||||||
this.addMouseListener(new MouseAdapter() {
|
this.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent mouseEvent) {
|
public void mousePressed(MouseEvent mouseEvent) {
|
||||||
|
if(!marked) {
|
||||||
|
addAnimation(new ColorAnimation(CheckBox.this, getAccentColor(), getForegroundColor(), 100));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addAnimation(new ColorAnimation(CheckBox.this, getForegroundColor(), getAccentColor(), 100));
|
||||||
|
}
|
||||||
marked = !marked;
|
marked = !marked;
|
||||||
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent mouseEvent) {
|
public void mouseEntered(MouseEvent mouseEvent) {
|
||||||
hovered = true;
|
if(!marked) {
|
||||||
|
addAnimation(new ColorAnimation(CheckBox.this, getBackgroundColor(), getAccentColor(), 100));
|
||||||
|
}
|
||||||
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent mouseEvent) {
|
public void mouseExited(MouseEvent mouseEvent) {
|
||||||
hovered = false;
|
if(!marked) {
|
||||||
|
addAnimation(new ColorAnimation(CheckBox.this, getAccentColor(), getBackgroundColor(), 100));
|
||||||
|
}
|
||||||
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -92,19 +103,11 @@ public class CheckBox extends Visual {
|
|||||||
public void paint(BufferedImage imageBuffer) {
|
public void paint(BufferedImage imageBuffer) {
|
||||||
Graphics2D g = imageBuffer.createGraphics();
|
Graphics2D g = imageBuffer.createGraphics();
|
||||||
|
|
||||||
//Set Transparency
|
g.setColor(getPaintColor());
|
||||||
g.setComposite(AlphaComposite.Clear);
|
|
||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
|
||||||
g.setComposite(AlphaComposite.Src);
|
|
||||||
|
|
||||||
if(hovered && !marked) {
|
g.fillRect(1, 1, getHeight() - 1, getHeight() - 1);
|
||||||
g.setColor(getAccentColor());
|
|
||||||
g.fillRect(0, 0, getHeight() - 1, getHeight() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(marked) {
|
if(marked) {
|
||||||
g.setColor(getForegroundColor());
|
|
||||||
g.fillRect(1, 1, getHeight() - 2, getHeight() - 2);
|
|
||||||
|
|
||||||
if(icon != null) {
|
if(icon != null) {
|
||||||
int iconWidth = icon.getWidth();
|
int iconWidth = icon.getWidth();
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
package guiTree.Components;
|
package guiTree.Components;
|
||||||
|
|
||||||
import guiTree.Helper.Debugger;
|
import guiTree.Animations.LocationAnimation;
|
||||||
|
import guiTree.Helper.Point2;
|
||||||
import guiTree.Visual;
|
import guiTree.Visual;
|
||||||
import guiTree.events.MouseAdapter;
|
import guiTree.events.MouseAdapter;
|
||||||
|
|
||||||
|
import java.awt.event.MouseWheelEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public class ScrollPanel extends Visual {
|
public class ScrollPanel extends Visual {
|
||||||
|
private List<VisualLocation> children;
|
||||||
|
|
||||||
private float positionX;
|
private float positionX;
|
||||||
private float positionY;
|
private float positionY;
|
||||||
@@ -19,48 +26,187 @@ public class ScrollPanel extends Visual {
|
|||||||
public ScrollPanel() {
|
public ScrollPanel() {
|
||||||
super();
|
super();
|
||||||
setName("ScrollPanel");
|
setName("ScrollPanel");
|
||||||
horizontalScrollBar = new Slider(Slider.Direction.Horizontal);
|
children = new ArrayList<>();
|
||||||
verticalScrollBar = new Slider(Slider.Direction.Vertical);
|
addMouseListener(new BarListener());
|
||||||
verticalScrollBar.setHasBorder(true);
|
addMouseWheelListener(new MouseWheelListener());
|
||||||
horizontalScrollBar.setHasBorder(true);
|
|
||||||
addVisual(verticalScrollBar);
|
|
||||||
addVisual(horizontalScrollBar);
|
|
||||||
verticalScrollBar.setName("vertical scroll bar");
|
|
||||||
horizontalScrollBar.setName("horizontal scroll bar");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSize() {
|
public void setSize() {
|
||||||
super.setSize();
|
super.setSize();
|
||||||
if(verticalScrollBar != null && horizontalScrollBar != null) {
|
if (getFarthestX() > getWidth()) {
|
||||||
verticalScrollBar.setSize(20, getHeight() - 20);
|
if (horizontalScrollBar == null) {
|
||||||
horizontalScrollBar.setSize(getWidth() - 20, 20);
|
horizontalScrollBar = new Slider(Slider.Direction.Horizontal);
|
||||||
return;
|
horizontalScrollBar.setName(getName() + " horizontal scroll bar");
|
||||||
|
super.addVisual(horizontalScrollBar);
|
||||||
|
horizontalScrollBar.setWidth(1.0f);
|
||||||
|
horizontalScrollBar.setHeight(20);
|
||||||
|
}
|
||||||
|
horizontalScrollBar.setSliderSize((float)getWidth() / getFarthestX());
|
||||||
|
horizontalScrollBar.setLocation(0, getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(horizontalScrollBar != null) {
|
if (getFarthestY() > getHeight()) {
|
||||||
horizontalScrollBar.setSize(getWidth(), 20);
|
if (verticalScrollBar == null) {
|
||||||
|
verticalScrollBar = new Slider(Slider.Direction.Vertical);
|
||||||
|
verticalScrollBar.setName(getName() + " vertical scroll bar");
|
||||||
|
super.addVisual(verticalScrollBar);
|
||||||
|
verticalScrollBar.setHeight(1.0f);
|
||||||
|
verticalScrollBar.setWidth(20);
|
||||||
|
}
|
||||||
|
verticalScrollBar.setSliderSize((float)getHeight() / getFarthestY());
|
||||||
|
verticalScrollBar.setLocation(getWidth(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addVisual(Visual v) {
|
||||||
|
if(v.getWidth() + v.getLocationX() > getFarthestX()) {
|
||||||
|
if (v.getWidth() + v.getLocationX() > getWidth()) {
|
||||||
|
if (horizontalScrollBar == null) {
|
||||||
|
horizontalScrollBar = new Slider(Slider.Direction.Horizontal);
|
||||||
|
horizontalScrollBar.setName(getName() + " horizontal scroll bar");
|
||||||
|
horizontalScrollBar.setWidth(1.0f);
|
||||||
|
horizontalScrollBar.setHeight(20);
|
||||||
|
super.addVisual(horizontalScrollBar);
|
||||||
|
}
|
||||||
|
horizontalScrollBar.setSliderSize((float)getWidth() / v.getWidth() + v.getLocationX());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(v.getHeight() + v.getLocationY() > getFarthestY()) {
|
||||||
|
if (v.getHeight() + v.getLocationY() > getHeight()) {
|
||||||
|
if (verticalScrollBar == null) {
|
||||||
|
verticalScrollBar = new Slider(Slider.Direction.Vertical);
|
||||||
|
verticalScrollBar.setName(getName() + " vertical scroll bar");
|
||||||
|
verticalScrollBar.setHeight(1.0f);
|
||||||
|
verticalScrollBar.setWidth(20);
|
||||||
|
super.addVisual(verticalScrollBar);
|
||||||
|
}
|
||||||
|
verticalScrollBar.setSliderSize((float)getHeight() / v.getHeight() + v.getLocationY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(verticalScrollBar != null) {
|
super.addVisual(v);
|
||||||
verticalScrollBar.setSize(20, getHeight());
|
children.add(new VisualLocation(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFarthestX() {
|
||||||
|
int max = 0;
|
||||||
|
for(VisualLocation visualLocation: children) {
|
||||||
|
if(max < visualLocation.v.getWidth() + visualLocation.originalLocation.x) {
|
||||||
|
max = visualLocation.v.getWidth() + visualLocation.originalLocation.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFarthestY() {
|
||||||
|
int max = 0;
|
||||||
|
for(VisualLocation visualLocation: children) {
|
||||||
|
if(max < visualLocation.v.getHeight() + visualLocation.originalLocation.y) {
|
||||||
|
max = visualLocation.v.getHeight() + visualLocation.originalLocation.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLocations() {
|
||||||
|
for(VisualLocation visualLocation:children) {
|
||||||
|
visualLocation.v.setLocation(visualLocation.originalLocation.x - Math.round(horizontalScrollBar.getSliderLocation() * (getFarthestX() - getWidth() + 20)),
|
||||||
|
visualLocation.originalLocation.y - Math.round(verticalScrollBar.getSliderLocation() * (getFarthestY() - getHeight() + 20)));
|
||||||
|
System.out.println("Moved: " + visualLocation.v + " from x: " + visualLocation.originalLocation + " to " + visualLocation.v.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleNotification(int notify) {
|
||||||
|
if(notify == Slider.SLIDER_MOVED) {
|
||||||
|
setLocations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(BufferedImage imageBuffer) {
|
public void paint(BufferedImage imageBuffer) {
|
||||||
Graphics2D g = imageBuffer.createGraphics();
|
Graphics2D g = imageBuffer.createGraphics();
|
||||||
|
g.setColor(getPaintColor());
|
||||||
if(getHasBorder()) {
|
if(getHasBorder()) {
|
||||||
g.setColor(getBackgroundColor());
|
g.fillRect(1, 1, getWidth() - 1, getHeight() - 1);
|
||||||
g.fillRect(1, 1, getWidth() - 2, getHeight() - 2);
|
|
||||||
g.setColor(getBorderColor());
|
g.setColor(getBorderColor());
|
||||||
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
g.setColor(getBackgroundColor());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.dispose();
|
g.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class BarListener extends MouseAdapter {
|
||||||
|
private boolean outHorizontal = false;
|
||||||
|
private boolean outVertical = false;
|
||||||
|
private LocationAnimation outAnimationHorizontal;
|
||||||
|
private LocationAnimation outAnimationVertical;
|
||||||
|
private LocationAnimation inAnimationHorizontal;
|
||||||
|
private LocationAnimation inAnimationVertical;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent mouseEvent) {
|
||||||
|
if(verticalScrollBar != null) {
|
||||||
|
if (mouseEvent.getX() > getWidth() - verticalScrollBar.getWidth() && mouseEvent.getY() > verticalScrollBar.getLocationY() && mouseEvent.getY() < verticalScrollBar.getHeight()) {
|
||||||
|
if (!outVertical) {
|
||||||
|
outAnimationVertical = new LocationAnimation(verticalScrollBar, verticalScrollBar.getLocation(), new Point2<>(getWidth() - verticalScrollBar.getWidth(), verticalScrollBar.getLocationY()), 300);
|
||||||
|
removeAnimation(inAnimationVertical);
|
||||||
|
addAnimation(outAnimationVertical);
|
||||||
|
outVertical = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (outVertical) {
|
||||||
|
inAnimationVertical = new LocationAnimation(verticalScrollBar, verticalScrollBar.getLocation(), new Point2<>(getWidth(), verticalScrollBar.getLocationY()), 300);
|
||||||
|
removeAnimation(outAnimationVertical);
|
||||||
|
addAnimation(inAnimationVertical);
|
||||||
|
outVertical = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(horizontalScrollBar != null) {
|
||||||
|
if (mouseEvent.getY() > getHeight() - horizontalScrollBar.getHeight() && mouseEvent.getX() > horizontalScrollBar.getLocationX() && mouseEvent.getX() < horizontalScrollBar.getWidth()) {
|
||||||
|
if (!outHorizontal) {
|
||||||
|
outAnimationHorizontal = new LocationAnimation(horizontalScrollBar, horizontalScrollBar.getLocation(), new Point2<>(horizontalScrollBar.getLocationX(), getHeight() - horizontalScrollBar.getHeight()), 300);
|
||||||
|
removeAnimation(inAnimationHorizontal);
|
||||||
|
addAnimation(outAnimationHorizontal);
|
||||||
|
outHorizontal = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (outHorizontal) {
|
||||||
|
inAnimationHorizontal = new LocationAnimation(horizontalScrollBar, horizontalScrollBar.getLocation(), new Point2<>(horizontalScrollBar.getLocationX(), getHeight()), 300);
|
||||||
|
removeAnimation(outAnimationHorizontal);
|
||||||
|
addAnimation(inAnimationHorizontal);
|
||||||
|
outHorizontal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MouseWheelListener extends MouseAdapter {
|
||||||
|
@Override
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
||||||
|
if(mouseWheelEvent.isShiftDown()) {
|
||||||
|
horizontalScrollBar.moveSlider(mouseWheelEvent.getWheelRotation() * 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verticalScrollBar.moveSlider(mouseWheelEvent.getWheelRotation() * 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class VisualLocation {
|
||||||
|
Visual v;
|
||||||
|
Point2<Integer> originalLocation;
|
||||||
|
|
||||||
|
public VisualLocation(Visual v) {
|
||||||
|
this.v = v;
|
||||||
|
originalLocation = v.getLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public class Slider extends Visual {
|
public class Slider extends Visual {
|
||||||
|
public static final int SLIDER_MOVED = 3;
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
Vertical,
|
Vertical,
|
||||||
Horizontal
|
Horizontal
|
||||||
@@ -84,19 +86,33 @@ public class Slider extends Visual {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getSliderLocation() {
|
public float getSliderLocation() {
|
||||||
|
int availableSpace;
|
||||||
if(direction == Direction.Vertical) {
|
if(direction == Direction.Vertical) {
|
||||||
return (float)slider.getLocationY() / getHeight();
|
availableSpace = getHeight() - button1.getHeight() - slider.getHeight() - button2.getHeight();
|
||||||
}
|
int sliderY = slider.getLocationY() - button1.getHeight();
|
||||||
else {
|
return (float)sliderY / availableSpace;
|
||||||
return (float)slider.getLocationX() / getWidth();
|
|
||||||
}
|
}
|
||||||
|
availableSpace = getWidth() - button1.getWidth() - slider.getWidth() - button2.getWidth();
|
||||||
|
int sliderX = slider.getLocationX() - button1.getWidth();
|
||||||
|
return (float)sliderX / availableSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSliderSize(int width, int height) {
|
public float getSliderSize() {
|
||||||
slider.setSize(width, height);
|
if(direction == Direction.Vertical) {
|
||||||
|
return (float)slider.getHeight() / getHeight();
|
||||||
|
}
|
||||||
|
return (float)slider.getWidth() / getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveSlider(int offset) {
|
public void setSliderSize(Float size) {
|
||||||
|
if(direction == Direction.Vertical) {
|
||||||
|
slider.setHeight(Math.round(size * getHeight()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
slider.setWidth(Math.round(size * getWidth()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveSlider(Integer offset) {
|
||||||
if(direction == Direction.Vertical) {
|
if(direction == Direction.Vertical) {
|
||||||
if(slider.getLocationY() + slider.getHeight() + offset > getHeight() - button2.getHeight()) {
|
if(slider.getLocationY() + slider.getHeight() + offset > getHeight() - button2.getHeight()) {
|
||||||
slider.setLocationY(getHeight() - slider.getHeight() - button2.getHeight());
|
slider.setLocationY(getHeight() - slider.getHeight() - button2.getHeight());
|
||||||
@@ -119,6 +135,7 @@ public class Slider extends Visual {
|
|||||||
slider.setLocationX(Math.round(slider.getLocationX() + offset));
|
slider.setLocationX(Math.round(slider.getLocationX() + offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyParent(SLIDER_MOVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirection(Direction direction) {
|
public void setDirection(Direction direction) {
|
||||||
@@ -143,7 +160,7 @@ public class Slider extends Visual {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveSlider(float offset) {
|
public void moveSlider(Float offset) {
|
||||||
if(direction == Direction.Vertical) {
|
if(direction == Direction.Vertical) {
|
||||||
moveSlider(Math.round(offset * getHeight()));
|
moveSlider(Math.round(offset * getHeight()));
|
||||||
return;
|
return;
|
||||||
@@ -198,13 +215,13 @@ public class Slider extends Visual {
|
|||||||
button1.setSize(Math.round(0.7f * getWidth()), Math.round(0.7f * getWidth()));
|
button1.setSize(Math.round(0.7f * getWidth()), Math.round(0.7f * getWidth()));
|
||||||
button2.setSize(button1.getWidth(), button1.getHeight());
|
button2.setSize(button1.getWidth(), button1.getHeight());
|
||||||
button2.setLocation(0, getHeight() - button2.getHeight());
|
button2.setLocation(0, getHeight() - button2.getHeight());
|
||||||
slider.setSize(getWidth() / 2, 40);
|
slider.setWidth(getWidth() / 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
button1.setSize(Math.round(0.7f * getHeight()), Math.round(0.7f * getHeight()));
|
button1.setSize(Math.round(0.7f * getHeight()), Math.round(0.7f * getHeight()));
|
||||||
button2.setSize(button1.getWidth(), button1.getHeight());
|
button2.setSize(button1.getWidth(), button1.getHeight());
|
||||||
button2.setLocation(getWidth() - button2.getWidth(), 0);
|
button2.setLocation(getWidth() - button2.getWidth(), 0);
|
||||||
slider.setSize(40, getHeight() / 2);
|
slider.setHeight(getHeight() / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +235,7 @@ public class Slider extends Visual {
|
|||||||
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
|
||||||
}
|
}
|
||||||
g.setColor(getBackgroundColor());
|
g.setColor(getBackgroundColor());
|
||||||
|
|
||||||
if(direction == Direction.Vertical) {
|
if(direction == Direction.Vertical) {
|
||||||
int x1 = Math.round(0.15f * getWidth());
|
int x1 = Math.round(0.15f * getWidth());
|
||||||
int y1 = button1.getHeight();
|
int y1 = button1.getHeight();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package guiTree.Components;
|
package guiTree.Components;
|
||||||
|
|
||||||
|
import guiTree.Animations.ColorAnimation;
|
||||||
import guiTree.Helper.Debugger;
|
import guiTree.Helper.Debugger;
|
||||||
import guiTree.Visual;
|
import guiTree.Visual;
|
||||||
import guiTree.events.MouseAdapter;
|
import guiTree.events.MouseAdapter;
|
||||||
@@ -38,20 +39,31 @@ public class ToggleButton extends Visual {
|
|||||||
this.addMouseListener(new MouseAdapter() {
|
this.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent mouseEvent) {
|
public void mousePressed(MouseEvent mouseEvent) {
|
||||||
|
if(pressed) {
|
||||||
|
addAnimation(new ColorAnimation(ToggleButton.this, getForegroundColor(), getAccentColor(), 100));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addAnimation(new ColorAnimation(ToggleButton.this, getAccentColor(), getForegroundColor(), 100));
|
||||||
|
}
|
||||||
pressed = !pressed;
|
pressed = !pressed;
|
||||||
|
|
||||||
Debugger.log("Pressed: " + getName(), Debugger.Tag.LISTENER);
|
Debugger.log("Pressed: " + getName(), Debugger.Tag.LISTENER);
|
||||||
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from pressed: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent mouseEvent) {
|
public void mouseEntered(MouseEvent mouseEvent) {
|
||||||
hovered = true;
|
if(!pressed) {
|
||||||
|
addAnimation(new ColorAnimation(ToggleButton.this, getBackgroundColor(), getAccentColor(), 100));
|
||||||
|
}
|
||||||
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from entered: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent mouseEvent) {
|
public void mouseExited(MouseEvent mouseEvent) {
|
||||||
hovered = false;
|
if(!pressed) {
|
||||||
|
addAnimation(new ColorAnimation(ToggleButton.this, getAccentColor(), getBackgroundColor(), 100));
|
||||||
|
}
|
||||||
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
Debugger.log("Calling repaint from exited: " + getName(), Debugger.Tag.PAINTING);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -67,22 +79,7 @@ public class ToggleButton extends Visual {
|
|||||||
{
|
{
|
||||||
//Get Graphics
|
//Get Graphics
|
||||||
Graphics2D g = imageBuffer.createGraphics();
|
Graphics2D g = imageBuffer.createGraphics();
|
||||||
|
g.setColor(getPaintColor());
|
||||||
//Set Transparency
|
|
||||||
g.setComposite(AlphaComposite.Clear);
|
|
||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
|
||||||
g.setComposite(AlphaComposite.Src);
|
|
||||||
|
|
||||||
//Choose background
|
|
||||||
if(hovered) {
|
|
||||||
g.setColor(this.getAccentColor());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g.setColor(this.getBackgroundColor());
|
|
||||||
}
|
|
||||||
if(pressed) {
|
|
||||||
g.setColor(this.getForegroundColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw Button
|
//Draw Button
|
||||||
if(getHasBorder()) {
|
if(getHasBorder()) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package guiTree;
|
|||||||
import guiTree.Helper.Debugger;
|
import guiTree.Helper.Debugger;
|
||||||
import guiTree.Helper.Timer;
|
import guiTree.Helper.Timer;
|
||||||
import guiTree.events.KeyEventGetter;
|
import guiTree.events.KeyEventGetter;
|
||||||
import guiTree.events.MouseWheelGetter;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ public class Debugger {
|
|||||||
public enum Tag {
|
public enum Tag {
|
||||||
LISTENER(false),
|
LISTENER(false),
|
||||||
PAINTING(false),
|
PAINTING(false),
|
||||||
FPS(false),
|
FPS(true),
|
||||||
ANIMATIONS(true),
|
ANIMATIONS(false),
|
||||||
PARSING(false);
|
PARSING(false);
|
||||||
|
|
||||||
public boolean value;
|
public boolean value;
|
||||||
|
|||||||
@@ -12,4 +12,9 @@ public class Point2<T> {
|
|||||||
public boolean equals(Point2<T> point2) {
|
public boolean equals(Point2<T> point2) {
|
||||||
return x == point2.y && y == point2.y;
|
return x == point2.y && y == point2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Point2 x:" + x + " y: " + y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,9 @@ public class Point3<T> {
|
|||||||
public boolean equals(Point3<T> point3) {
|
public boolean equals(Point3<T> point3) {
|
||||||
return x == point3.x && y == point3.y && z == point3.z;
|
return x == point3.x && y == point3.y && z == point3.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Point2 x:" + x + " y: " + y + " z: " + z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,9 @@ public class Point4<T> {
|
|||||||
public boolean equals(Point4<T> point4) {
|
public boolean equals(Point4<T> point4) {
|
||||||
return a == point4.a && b == point4.b && c == point4.c && d == point4.d;
|
return a == point4.a && b == point4.b && c == point4.c && d == point4.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Point2 a:" + a + " b: " + b + " c: " + c + " d: " + d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package guiTree.events;
|
package guiTree;
|
||||||
|
|
||||||
import guiTree.Window;
|
|
||||||
|
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
@@ -14,6 +12,6 @@ public class MouseWheelGetter implements MouseWheelListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
||||||
|
callingWindow.mouseWheelMoved(mouseWheelEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,7 @@ public class Visual {
|
|||||||
private Color accentColor;
|
private Color accentColor;
|
||||||
private Color fontColor;
|
private Color fontColor;
|
||||||
private Color borderColor;
|
private Color borderColor;
|
||||||
|
private Color paintColor;
|
||||||
private Boolean active;
|
private Boolean active;
|
||||||
private Boolean dirty;
|
private Boolean dirty;
|
||||||
private static Visual entered;
|
private static Visual entered;
|
||||||
@@ -135,6 +136,22 @@ public class Visual {
|
|||||||
notifyParent(SIZE_CHANGED);
|
notifyParent(SIZE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHeight(Integer height) {
|
||||||
|
setSize(getWidth(), height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Integer width) {
|
||||||
|
setSize(width, getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(Float height) {
|
||||||
|
setSize(relativeWidth, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Float width) {
|
||||||
|
setSize(width, relativeHeight);
|
||||||
|
}
|
||||||
|
|
||||||
public void setSize(Integer width, Integer height) {
|
public void setSize(Integer width, Integer height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
@@ -188,6 +205,7 @@ public class Visual {
|
|||||||
|
|
||||||
public void setBackgroundColor(Color backgroundColor) {
|
public void setBackgroundColor(Color backgroundColor) {
|
||||||
this.backgroundColor = backgroundColor;
|
this.backgroundColor = backgroundColor;
|
||||||
|
this.paintColor = backgroundColor;
|
||||||
propagateDirt();
|
propagateDirt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,14 +216,22 @@ public class Visual {
|
|||||||
|
|
||||||
public void setFontColor(Color fontColor) {
|
public void setFontColor(Color fontColor) {
|
||||||
this.fontColor = fontColor;
|
this.fontColor = fontColor;
|
||||||
|
propagateDirt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccentColor(Color accentColor) {
|
public void setAccentColor(Color accentColor) {
|
||||||
this.accentColor = accentColor;
|
this.accentColor = accentColor;
|
||||||
|
propagateDirt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBorderColor(Color borderColor) {
|
public void setBorderColor(Color borderColor) {
|
||||||
this.borderColor = borderColor;
|
this.borderColor = borderColor;
|
||||||
|
propagateDirt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaintColor(Color paintColor) {
|
||||||
|
this.paintColor = paintColor;
|
||||||
|
propagateDirt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHasBorder(Boolean hasBorder) {
|
public void setHasBorder(Boolean hasBorder) {
|
||||||
@@ -265,6 +291,10 @@ public class Visual {
|
|||||||
return borderColor;
|
return borderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color getPaintColor() {
|
||||||
|
return paintColor;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getHasBorder() {
|
public Boolean getHasBorder() {
|
||||||
return hasBorder;
|
return hasBorder;
|
||||||
}
|
}
|
||||||
@@ -360,7 +390,6 @@ public class Visual {
|
|||||||
if(!(this instanceof Window)){
|
if(!(this instanceof Window)){
|
||||||
long time = timer.stopTiming();
|
long time = timer.stopTiming();
|
||||||
Debugger.log("Finished Revalidating " + name + ": " + time, Debugger.Tag.PAINTING);
|
Debugger.log("Finished Revalidating " + name + ": " + time, Debugger.Tag.PAINTING);
|
||||||
parent.revalidate();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Window window = (Window)this;
|
Window window = (Window)this;
|
||||||
@@ -512,8 +541,8 @@ public class Visual {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
||||||
if(focused) {
|
if(entered.focused) {
|
||||||
for(MouseWheelListener mouseWheelListener: mouseWheelListeners) {
|
for(MouseWheelListener mouseWheelListener: entered.mouseWheelListeners) {
|
||||||
mouseWheelListener.mouseWheelMoved(mouseWheelEvent);
|
mouseWheelListener.mouseWheelMoved(mouseWheelEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,16 +94,18 @@ public class XAMLParser {
|
|||||||
}
|
}
|
||||||
for(Method method: methods){
|
for(Method method: methods){
|
||||||
Class<?>[] types = method.getParameterTypes();
|
Class<?>[] types = method.getParameterTypes();
|
||||||
for(int i = 0; i < types.length; i++){
|
if(types.length == values.size()) {
|
||||||
try{
|
for (int i = 0; i < types.length; i++) {
|
||||||
primitiveAttributes.add(valueConverter.objectCreatorFactory(types[i], values.get(i)));
|
try {
|
||||||
} catch (InvalidTypeException | NumberFormatException e){
|
primitiveAttributes.add(valueConverter.objectCreatorFactory(types[i], values.get(i)));
|
||||||
primitiveAttributes.clear();
|
} catch (InvalidTypeException | NumberFormatException e) {
|
||||||
break;
|
primitiveAttributes.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (primitiveAttributes.size() == types.length && types.length == values.size()) {
|
||||||
|
return primitiveAttributes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(primitiveAttributes.size() == types.length && types.length == values.size()){
|
|
||||||
return primitiveAttributes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.err.println("Could not find method " + methodName + " with parameters " + values);
|
System.err.println("Could not find method " + methodName + " with parameters " + values);
|
||||||
|
|||||||
Reference in New Issue
Block a user