mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
abstract class reorganization
sort properties by name
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package org.diylc.components;
|
||||||
|
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract implementation of {@link IDIYComponent} that contains component name
|
||||||
|
* and toString.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
@EditableProperty(defaultable = false)
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-12
@@ -2,9 +2,7 @@ package org.diylc.components;
|
|||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
|
||||||
import org.diylc.core.IDIYComponent;
|
public abstract class AbstractSinglePointComponent extends AbstractComponent<Void> {
|
||||||
|
|
||||||
public abstract class AbstractSinglePointComponent implements IDIYComponent<Void> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -25,15 +23,6 @@ public abstract class AbstractSinglePointComponent implements IDIYComponent<Void
|
|||||||
this.point.setLocation(point);
|
this.point.setLocation(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Pad";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public Void getValue() {
|
public Void getValue() {
|
||||||
|
|||||||
+1
-12
@@ -1,26 +1,15 @@
|
|||||||
package org.diylc.components;
|
package org.diylc.components;
|
||||||
|
|
||||||
import org.diylc.core.IDIYComponent;
|
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
public abstract class AbstractTransparentComponent<T> implements IDIYComponent<T> {
|
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static byte MAX_ALPHA = 127;
|
public static byte MAX_ALPHA = 127;
|
||||||
|
|
||||||
protected String name = "New Component";
|
|
||||||
protected byte alpha = MAX_ALPHA;
|
protected byte alpha = MAX_ALPHA;
|
||||||
|
|
||||||
@EditableProperty(defaultable = false)
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Byte getAlpha() {
|
public Byte getAlpha() {
|
||||||
return alpha;
|
return alpha;
|
||||||
|
|||||||
+16
@@ -4,6 +4,7 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
|
import org.diylc.common.PropertyWrapper;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
public class ComparatorFactory {
|
public class ComparatorFactory {
|
||||||
@@ -12,6 +13,7 @@ public class ComparatorFactory {
|
|||||||
|
|
||||||
private Comparator<IDIYComponent<?>> componentNameComparator;
|
private Comparator<IDIYComponent<?>> componentNameComparator;
|
||||||
private Comparator<ComponentType> componentTypeComparator;
|
private Comparator<ComponentType> componentTypeComparator;
|
||||||
|
private Comparator<PropertyWrapper> propertyNameComparator;
|
||||||
|
|
||||||
public static ComparatorFactory getInstance() {
|
public static ComparatorFactory getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@@ -64,4 +66,18 @@ public class ComparatorFactory {
|
|||||||
};
|
};
|
||||||
return componentZOrderComparator;
|
return componentZOrderComparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Comparator<PropertyWrapper> getPropertyNameComparator() {
|
||||||
|
if (propertyNameComparator == null) {
|
||||||
|
propertyNameComparator = new Comparator<PropertyWrapper>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(PropertyWrapper o1, PropertyWrapper o2) {
|
||||||
|
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return propertyNameComparator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@ import java.awt.RenderingHints;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -184,6 +185,7 @@ public class ComponentProcessor {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
Collections.sort(properties, ComparatorFactory.getInstance().getPropertyNameComparator());
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user