mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
redo shape class hierarchy
This commit is contained in:
+108
@@ -0,0 +1,108 @@
|
||||
package org.diylc.components.shapes;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
public abstract class AbstractShape extends AbstractTransparentComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size DEFAULT_WIDTH = new Size(0.6d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(0.4d, SizeUnit.in);
|
||||
|
||||
protected String value = "";
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point(0, 0),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||
(int) DEFAULT_HEIGHT.convertToPixels()) };
|
||||
protected Point firstPoint = new Point();
|
||||
protected Point secondPoint = new Point();
|
||||
|
||||
protected Color color = COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected Size borderThickness = new Size(0.2d, SizeUnit.mm);
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border thickness")
|
||||
public Size getBorderThickness() {
|
||||
return borderThickness;
|
||||
}
|
||||
|
||||
public void setBorderThickness(Size borderThickness) {
|
||||
this.borderThickness = borderThickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
firstPoint.setLocation(
|
||||
Math.min(controlPoints[0].x, controlPoints[1].x), Math.min(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
secondPoint.setLocation(Math
|
||||
.max(controlPoints[0].x, controlPoints[1].x), Math.max(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
+2
-95
@@ -1,46 +1,22 @@
|
||||
package org.diylc.components.shapes;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Ellipse", author = "Branislav Stojkovic", category = "Shapes", instanceNamePrefix = "ELL", description = "Elliptical area", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false)
|
||||
public class Ellipse extends AbstractTransparentComponent<Void> {
|
||||
public class Ellipse extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(1.2d, SizeUnit.in);
|
||||
|
||||
protected String value = "";
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point(0, 0),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||
(int) DEFAULT_HEIGHT.convertToPixels()) };
|
||||
protected Point firstPoint = new Point();
|
||||
protected Point secondPoint = new Point();
|
||||
|
||||
protected Color color = COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected Size borderThickness = new Size(0.2d, SizeUnit.mm);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project,
|
||||
@@ -66,65 +42,7 @@ public class Ellipse extends AbstractTransparentComponent<Void> {
|
||||
: borderColor);
|
||||
g2d.drawOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x,
|
||||
secondPoint.y - firstPoint.y);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border thickness")
|
||||
public Size getBorderThickness() {
|
||||
return borderThickness;
|
||||
}
|
||||
|
||||
public void setBorderThickness(Size borderThickness) {
|
||||
this.borderThickness = borderThickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
firstPoint.setLocation(
|
||||
Math.min(controlPoints[0].x, controlPoints[1].x), Math.min(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
secondPoint.setLocation(Math
|
||||
.max(controlPoints[0].x, controlPoints[1].x), Math.max(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
@@ -136,15 +54,4 @@ public class Ellipse extends AbstractTransparentComponent<Void> {
|
||||
g2d.drawOval(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||
/ factor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
|
||||
+12
-84
@@ -8,39 +8,30 @@ import java.awt.Point;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Polygon", author = "Branislav Stojkovic", category = "Shapes", instanceNamePrefix = "POLY", description = "Polygonal area", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false)
|
||||
public class Polygon extends AbstractTransparentComponent<Void> {
|
||||
public class Polygon extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(1.2d, SizeUnit.in);
|
||||
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point(0, 0),
|
||||
new Point(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||
(int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(), 0) };
|
||||
|
||||
protected Color color = COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected Size borderThickness = new Size(0.2d, SizeUnit.mm);
|
||||
protected PointCount pointCount = PointCount._4;
|
||||
|
||||
public Polygon() {
|
||||
super();
|
||||
this.controlPoints = new Point[] {
|
||||
new Point(0, 0),
|
||||
new Point(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||
(int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(), 0) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||
@@ -73,58 +64,6 @@ public class Polygon extends AbstractTransparentComponent<Void> {
|
||||
g2d.drawPolygon(xPoints, yPoints, controlPoints.length);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border thickness")
|
||||
public Size getBorderThickness() {
|
||||
return borderThickness;
|
||||
}
|
||||
|
||||
public void setBorderThickness(Size borderThickness) {
|
||||
this.borderThickness = borderThickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Edges")
|
||||
public PointCount getPointCount() {
|
||||
return pointCount;
|
||||
@@ -145,18 +84,7 @@ public class Polygon extends AbstractTransparentComponent<Void> {
|
||||
}
|
||||
}
|
||||
this.pointCount = pointCount;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
|
||||
+1
-90
@@ -1,18 +1,14 @@
|
||||
package org.diylc.components.shapes;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -20,27 +16,11 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Rectangle", author = "Branislav Stojkovic", category = "Shapes", instanceNamePrefix = "RECT", description = "Ractangular area, with or withouth rounded edges", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false)
|
||||
public class Rectangle extends AbstractTransparentComponent<Void> {
|
||||
public class Rectangle extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(1.2d, SizeUnit.in);
|
||||
|
||||
protected String value = "";
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point(0, 0),
|
||||
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||
(int) DEFAULT_HEIGHT.convertToPixels()) };
|
||||
protected Point firstPoint = new Point();
|
||||
protected Point secondPoint = new Point();
|
||||
|
||||
protected Color color = COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||
protected Size borderThickness = new Size(0.2d, SizeUnit.mm);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||
@@ -70,33 +50,6 @@ public class Rectangle extends AbstractTransparentComponent<Void> {
|
||||
- firstPoint.x, secondPoint.y - firstPoint.y, radius, radius);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border thickness")
|
||||
public Size getBorderThickness() {
|
||||
return borderThickness;
|
||||
}
|
||||
|
||||
public void setBorderThickness(Size borderThickness) {
|
||||
this.borderThickness = borderThickness;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Radius")
|
||||
public Size getEdgeRadius() {
|
||||
return edgeRadius;
|
||||
@@ -106,37 +59,6 @@ public class Rectangle extends AbstractTransparentComponent<Void> {
|
||||
this.edgeRadius = edgeRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
firstPoint.setLocation(
|
||||
Math.min(controlPoints[0].x, controlPoints[1].x), Math.min(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
secondPoint.setLocation(Math
|
||||
.max(controlPoints[0].x, controlPoints[1].x), Math.max(
|
||||
controlPoints[0].y, controlPoints[1].y));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
@@ -147,15 +69,4 @@ public class Rectangle extends AbstractTransparentComponent<Void> {
|
||||
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||
/ factor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user