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:
@@ -1,7 +1,6 @@
|
||||
package parser;
|
||||
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import guiTree.Components.Decoarations.Decoration;
|
||||
import guiTree.Components.Decorations.Decoration;
|
||||
import parser.converters.Converter;
|
||||
import guiTree.Helper.Debugger;
|
||||
import guiTree.Visual;
|
||||
@@ -18,6 +17,7 @@ import java.util.List;
|
||||
public class XAMLParser {
|
||||
private final static String packageGuiTree = "guiTree.";
|
||||
private final static String packageComponents = "guiTree.Components.";
|
||||
private final static String packageDecorations = "guiTree.Components.Decorations.";
|
||||
private static Converter valueConverter = new Converter();
|
||||
|
||||
private static void setAttributes(Object object, NamedNodeMap attributeList){
|
||||
@@ -102,7 +102,7 @@ public class XAMLParser {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
try {
|
||||
primitiveAttributes.add(valueConverter.objectCreatorFactory(types[i], values.get(i)));
|
||||
} catch (InvalidTypeException | NumberFormatException e) {
|
||||
} catch (InvalidClassException | NumberFormatException e) {
|
||||
primitiveAttributes.clear();
|
||||
break;
|
||||
}
|
||||
@@ -122,7 +122,12 @@ public class XAMLParser {
|
||||
parentClass = Class.forName(packageComponents.concat(parentNode.getNodeName()));
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
parentClass = Class.forName(packageGuiTree.concat(parentNode.getNodeName()));
|
||||
try {
|
||||
parentClass = Class.forName(packageGuiTree.concat(parentNode.getNodeName()));
|
||||
}
|
||||
catch (ClassNotFoundException f) {
|
||||
parentClass = Class.forName(packageDecorations.concat(parentNode.getNodeName()));
|
||||
}
|
||||
}
|
||||
Debugger.log("Parsing " + parentClass, Debugger.Tag.PARSING);
|
||||
Object parentObject = parentClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package parser.converters;
|
||||
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import guiTree.Components.Slider;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.InvalidClassException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Converter {
|
||||
@@ -24,10 +24,10 @@ public class Converter {
|
||||
this.converterTable.put(Slider.Direction.class, new DirectionConverter());
|
||||
}
|
||||
|
||||
public Object objectCreatorFactory (Class<?> type, String content) throws InvalidTypeException {
|
||||
public Object objectCreatorFactory (Class<?> type, String content) throws InvalidClassException {
|
||||
if(this.converterTable.containsKey(type)) {
|
||||
return this.converterTable.get(type).convert(content);
|
||||
}
|
||||
throw new InvalidTypeException();
|
||||
throw new InvalidClassException(type.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package parser.converters;
|
||||
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import java.io.InvalidClassException;
|
||||
|
||||
public interface ConverterInterface<T> {
|
||||
T convert(String content) throws InvalidTypeException;
|
||||
T convert(String content) throws InvalidClassException;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package parser.converters;
|
||||
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import guiTree.Components.Slider;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
|
||||
public class DirectionConverter implements ConverterInterface<Slider.Direction> {
|
||||
@Override
|
||||
public Slider.Direction convert(String content) throws InvalidTypeException {
|
||||
public Slider.Direction convert(String content) throws InvalidClassException {
|
||||
content = content.toLowerCase();
|
||||
if(content.equals("horizontal")) {
|
||||
return Slider.Direction.Horizontal;
|
||||
@@ -13,6 +14,6 @@ public class DirectionConverter implements ConverterInterface<Slider.Direction>
|
||||
if(content.equals("vertical")) {
|
||||
return Slider.Direction.Vertical;
|
||||
}
|
||||
throw new InvalidTypeException();
|
||||
throw new InvalidClassException(Slider.Direction.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package parser.converters;
|
||||
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import java.io.InvalidClassException;
|
||||
|
||||
public class FloatConverter implements ConverterInterface<Float> {
|
||||
|
||||
@Override
|
||||
public Float convert(String content) throws InvalidTypeException {
|
||||
public Float convert(String content) throws InvalidClassException {
|
||||
content = content.replaceAll(" ", "");
|
||||
|
||||
if(content.toLowerCase().charAt(content.length() - 1) != 'f') {
|
||||
throw new InvalidTypeException();
|
||||
throw new InvalidClassException(Float.class.getName());
|
||||
}
|
||||
content = content.substring(0, content.length() - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user