mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
added mirror
This commit is contained in:
@@ -241,16 +241,6 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
*/
|
*/
|
||||||
void setMetric(boolean isMetric);
|
void setMetric(boolean isMetric);
|
||||||
|
|
||||||
/**
|
|
||||||
* Groups all selected components.
|
|
||||||
*/
|
|
||||||
void groupSelectedComponents();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ungroups all selected components.
|
|
||||||
*/
|
|
||||||
void ungroupSelectedComponents();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks or unlocks the specified layer. All components within +- 0.5 range will be affected by
|
* Locks or unlocks the specified layer. All components within +- 0.5 range will be affected by
|
||||||
* the change as well.
|
* the change as well.
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
package org.diylc.common;
|
package org.diylc.common;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.diylc.core.ExpansionMode;
|
import org.diylc.core.ExpansionMode;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
public interface ISelectionProcessor {
|
public interface ISelectionProcessor {
|
||||||
|
|
||||||
|
public static final int CLOCKWISE = 1;
|
||||||
|
public static final int COUNTER_CLOCKWISE = 1;
|
||||||
|
|
||||||
|
public static final int HORIZONTAL = 0;
|
||||||
|
public static final int VERTICAL = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current {@link ComponentTransferable}.
|
* Returns the current {@link ComponentTransferable}.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<IDIYComponent<?>> getSelectedComponents();
|
Collection<IDIYComponent<?>> getSelectedComponents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the selection with the specified list of component. Also, updates control point map
|
* Updates the selection with the specified list of component. Also, updates control point map
|
||||||
@@ -21,7 +28,7 @@ public interface ISelectionProcessor {
|
|||||||
*
|
*
|
||||||
* @param newSelection
|
* @param newSelection
|
||||||
*/
|
*/
|
||||||
void updateSelection(List<IDIYComponent<?>> newSelection);
|
void updateSelection(Collection<IDIYComponent<?>> newSelection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all components at the specified location, sorted by z-index from top to bottom.
|
* Finds all components at the specified location, sorted by z-index from top to bottom.
|
||||||
@@ -53,4 +60,16 @@ public interface ISelectionProcessor {
|
|||||||
* @param direction 1 for clockwise, -1 for counter-clockwise
|
* @param direction 1 for clockwise, -1 for counter-clockwise
|
||||||
*/
|
*/
|
||||||
void rotateSelection(int direction);
|
void rotateSelection(int direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Groups all selected components.
|
||||||
|
*/
|
||||||
|
void groupSelectedComponents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ungroups all selected components.
|
||||||
|
*/
|
||||||
|
void ungroupSelectedComponents();
|
||||||
|
|
||||||
|
void mirrorSelection(int direction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ 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.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -185,19 +187,22 @@ public class ComponentProcessor {
|
|||||||
* @param selectedComponents
|
* @param selectedComponents
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<PropertyWrapper> getMutualSelectionProperties(List<IDIYComponent<?>> selectedComponents) throws Exception {
|
public List<PropertyWrapper> getMutualSelectionProperties(Collection<IDIYComponent<?>> selectedComponents) throws Exception {
|
||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>();
|
List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>();
|
||||||
IDIYComponent<?> firstComponent = selectedComponents.get(0);
|
|
||||||
|
List<IDIYComponent<?>> selectedList = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||||
|
|
||||||
|
IDIYComponent<?> firstComponent = selectedList.get(0);
|
||||||
properties.addAll(extractProperties(firstComponent.getClass()));
|
properties.addAll(extractProperties(firstComponent.getClass()));
|
||||||
// Initialize values
|
// Initialize values
|
||||||
for (PropertyWrapper property : properties) {
|
for (PropertyWrapper property : properties) {
|
||||||
property.readFrom(firstComponent);
|
property.readFrom(firstComponent);
|
||||||
}
|
}
|
||||||
for (int i = 1; i < selectedComponents.size(); i++) {
|
for (int i = 1; i < selectedComponents.size(); i++) {
|
||||||
IDIYComponent<?> component = selectedComponents.get(i);
|
IDIYComponent<?> component = selectedList.get(i);
|
||||||
List<PropertyWrapper> newProperties = extractProperties(component.getClass());
|
List<PropertyWrapper> newProperties = extractProperties(component.getClass());
|
||||||
for (PropertyWrapper property : newProperties) {
|
for (PropertyWrapper property : newProperties) {
|
||||||
property.readFrom(component);
|
property.readFrom(component);
|
||||||
@@ -219,14 +224,6 @@ public class ComponentProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for (PropertyWrapper property : properties) {
|
|
||||||
// try {
|
|
||||||
// property.readUniqueFrom(component);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
Collections.sort(properties, ComparatorFactory.getInstance().getDefaultPropertyComparator());
|
Collections.sort(properties, ComparatorFactory.getInstance().getDefaultPropertyComparator());
|
||||||
return properties;
|
return properties;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -97,7 +98,7 @@ public class DrawingManager {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<IDIYComponent<?>> drawProject(Graphics2D g2d, Project project, Set<DrawOption> drawOptions,
|
public List<IDIYComponent<?>> drawProject(Graphics2D g2d, Project project, Set<DrawOption> drawOptions,
|
||||||
IComponentFiler filter, Rectangle selectionRect, List<IDIYComponent<?>> selectedComponents,
|
IComponentFiler filter, Rectangle selectionRect, Collection<IDIYComponent<?>> selectedComponents,
|
||||||
Set<IDIYComponent<?>> lockedComponents, Set<IDIYComponent<?>> groupedComponents, List<Point> controlPointSlot,
|
Set<IDIYComponent<?>> lockedComponents, Set<IDIYComponent<?>> groupedComponents, List<Point> controlPointSlot,
|
||||||
List<IDIYComponent<?>> componentSlot, boolean dragInProgress) {
|
List<IDIYComponent<?>> componentSlot, boolean dragInProgress) {
|
||||||
failedComponents.clear();
|
failedComponents.clear();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.diylc.common.IComponentFiler;
|
|||||||
import org.diylc.common.IKeyProcessor;
|
import org.diylc.common.IKeyProcessor;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.common.ISelectionProcessor;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.common.OrientationHV;
|
import org.diylc.common.OrientationHV;
|
||||||
import org.diylc.common.PropertyWrapper;
|
import org.diylc.common.PropertyWrapper;
|
||||||
@@ -96,7 +97,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
// Maps component class names to ComponentType objects.
|
// Maps component class names to ComponentType objects.
|
||||||
private List<IPlugIn> plugIns;
|
private List<IPlugIn> plugIns;
|
||||||
|
|
||||||
private List<IDIYComponent<?>> selectedComponents;
|
private Set<IDIYComponent<?>> selectedComponents;
|
||||||
// Maps components that have at least one dragged point to set of indices
|
// Maps components that have at least one dragged point to set of indices
|
||||||
// that designate which of their control points are being dragged.
|
// that designate which of their control points are being dragged.
|
||||||
private Map<IDIYComponent<?>, Set<Integer>> controlPointMap;
|
private Map<IDIYComponent<?>, Set<Integer>> controlPointMap;
|
||||||
@@ -131,7 +132,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
this.view = view;
|
this.view = view;
|
||||||
plugIns = new ArrayList<IPlugIn>();
|
plugIns = new ArrayList<IPlugIn>();
|
||||||
messageDispatcher = new MessageDispatcher<EventType>(true);
|
messageDispatcher = new MessageDispatcher<EventType>(true);
|
||||||
selectedComponents = new ArrayList<IDIYComponent<?>>();
|
selectedComponents = new HashSet<IDIYComponent<?>>();
|
||||||
lockedComponents = new HashSet<IDIYComponent<?>>();
|
lockedComponents = new HashSet<IDIYComponent<?>>();
|
||||||
currentProject = new Project();
|
currentProject = new Project();
|
||||||
// cloner = new Cloner();
|
// cloner = new Cloner();
|
||||||
@@ -558,6 +559,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
|| !newSelection.contains(topComponent)) {
|
|| !newSelection.contains(topComponent)) {
|
||||||
newSelection.clear();
|
newSelection.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
newSelection.addAll(findAllGroupedComponents(topComponent));
|
newSelection.addAll(findAllGroupedComponents(topComponent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,7 +756,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IDIYComponent<?>> getSelectedComponents() {
|
public Collection<IDIYComponent<?>> getSelectedComponents() {
|
||||||
return selectedComponents;
|
return selectedComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1056,6 +1058,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
@Override
|
@Override
|
||||||
public void rotateSelection(int direction) {
|
public void rotateSelection(int direction) {
|
||||||
if (!selectedComponents.isEmpty()) {
|
if (!selectedComponents.isEmpty()) {
|
||||||
|
LOG.trace("Rotating selected components");
|
||||||
Project oldProject = currentProject.clone();
|
Project oldProject = currentProject.clone();
|
||||||
rotateComponents(this.selectedComponents, direction, isSnapToGrid());
|
rotateComponents(this.selectedComponents, direction, isSnapToGrid());
|
||||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
||||||
@@ -1069,7 +1072,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
* @param direction 1 for clockwise, -1 for counter-clockwise
|
* @param direction 1 for clockwise, -1 for counter-clockwise
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void rotateComponents(List<IDIYComponent<?>> components, int direction, boolean snapToGrid) {
|
private void rotateComponents(Collection<IDIYComponent<?>> components, int direction, boolean snapToGrid) {
|
||||||
Point center = getCenterOf(components, snapToGrid);
|
Point center = getCenterOf(components, snapToGrid);
|
||||||
|
|
||||||
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
|
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
|
||||||
@@ -1129,7 +1132,56 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point getCenterOf(List<IDIYComponent<?>> components, boolean snapToGrid) {
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void mirrorSelection(int direction) {
|
||||||
|
if (!selectedComponents.isEmpty()) {
|
||||||
|
LOG.trace("Mirroring selected components");
|
||||||
|
Project oldProject = currentProject.clone();
|
||||||
|
|
||||||
|
Point center = getCenterOf(selectedComponents, isSnapToGrid());
|
||||||
|
|
||||||
|
boolean canMirror = true;
|
||||||
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
|
ComponentType type =
|
||||||
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
|
if (!type.isStretchable() && component.getControlPointCount() > 1) {
|
||||||
|
canMirror = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!canMirror)
|
||||||
|
if (view.showConfirmDialog(
|
||||||
|
"Selection contains components that cannot bi mirrored. Do you want to exclude them?", "Mirror Selection",
|
||||||
|
IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
|
ComponentType type =
|
||||||
|
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||||
|
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||||
|
if (type.isStretchable() || component.getControlPointCount() == 1) {
|
||||||
|
drawingManager.invalidateComponent(component);
|
||||||
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
|
Point p = component.getControlPoint(i);
|
||||||
|
if (direction == ISelectionProcessor.HORIZONTAL) {
|
||||||
|
component.setControlPoint(new Point(p.x - 2 * (p.x - center.x), p.y), i);
|
||||||
|
} else {
|
||||||
|
component.setControlPoint(new Point(p.x, p.y - 2 * (p.y - center.y)), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
||||||
|
"Mirror Selection");
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point getCenterOf(Collection<IDIYComponent<?>> components, boolean snapToGrid) {
|
||||||
// Determine center of rotation
|
// Determine center of rotation
|
||||||
int minX = Integer.MAX_VALUE;
|
int minX = Integer.MAX_VALUE;
|
||||||
int minY = Integer.MAX_VALUE;
|
int minY = Integer.MAX_VALUE;
|
||||||
@@ -1455,8 +1507,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSelection(List<IDIYComponent<?>> newSelection) {
|
public void updateSelection(Collection<IDIYComponent<?>> newSelection) {
|
||||||
this.selectedComponents = newSelection;
|
this.selectedComponents = new HashSet<IDIYComponent<?>>(newSelection);
|
||||||
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||||
for (IDIYComponent<?> component : selectedComponents) {
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
Set<Integer> indices = new HashSet<Integer>();
|
Set<Integer> indices = new HashSet<Integer>();
|
||||||
@@ -1843,17 +1895,15 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (this.selectedComponents.isEmpty()) {
|
if (this.selectedComponents.isEmpty()) {
|
||||||
throw new RuntimeException("No components selected");
|
throw new RuntimeException("No components selected");
|
||||||
}
|
}
|
||||||
ComponentType selectedType =
|
ComponentType selectedType = null;
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
Iterator<IDIYComponent<?>> iterator = this.selectedComponents.iterator();
|
||||||
(Class<? extends IDIYComponent<?>>) this.selectedComponents.get(0).getClass());
|
while (iterator.hasNext()) {
|
||||||
for (int i = 1; i < this.selectedComponents.size(); i++) {
|
ComponentType type = ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) iterator.next().getClass());
|
||||||
ComponentType newType =
|
if (selectedType == null)
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
selectedType = type;
|
||||||
(Class<? extends IDIYComponent<?>>) this.selectedComponents.get(i).getClass());
|
else if (selectedType.getInstanceClass() != type.getInstanceClass())
|
||||||
if (newType.getInstanceClass() != selectedType.getInstanceClass()) {
|
|
||||||
throw new RuntimeException("Template can be applied on multiple components of the same type only");
|
throw new RuntimeException("Template can be applied on multiple components of the same type only");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return getTemplatesFor(selectedType.getCategory(), selectedType.getName());
|
return getTemplatesFor(selectedType.getCategory(), selectedType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -36,7 +36,8 @@ public enum IconLoader {
|
|||||||
"cloud_edit.png"), CloudUpload("cloud_upload.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
"cloud_edit.png"), CloudUpload("cloud_upload.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
||||||
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
||||||
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
|
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
|
||||||
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png");
|
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png"), FlipHorizontal("flip_horizontal.png"),
|
||||||
|
FlipVertical("flip_vertical.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 550 B |
Binary file not shown.
|
After Width: | Height: | Size: 528 B |
@@ -7,6 +7,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.print.PrinterException;
|
import java.awt.print.PrinterException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ import javax.swing.KeyStroke;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.common.ISelectionProcessor;
|
||||||
import org.diylc.common.ITask;
|
import org.diylc.common.ITask;
|
||||||
import org.diylc.common.PropertyWrapper;
|
import org.diylc.common.PropertyWrapper;
|
||||||
import org.diylc.core.ExpansionMode;
|
import org.diylc.core.ExpansionMode;
|
||||||
@@ -142,6 +144,10 @@ public class ActionFactory {
|
|||||||
public RotateSelectionAction createRotateSelectionAction(IPlugInPort plugInPort, int direction) {
|
public RotateSelectionAction createRotateSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||||
return new RotateSelectionAction(plugInPort, direction);
|
return new RotateSelectionAction(plugInPort, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MirrorSelectionAction createMirrorSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||||
|
return new MirrorSelectionAction(plugInPort, direction);
|
||||||
|
}
|
||||||
|
|
||||||
public SendToBackAction createSendToBackAction(IPlugInPort plugInPort) {
|
public SendToBackAction createSendToBackAction(IPlugInPort plugInPort) {
|
||||||
return new SendToBackAction(plugInPort);
|
return new SendToBackAction(plugInPort);
|
||||||
@@ -681,7 +687,7 @@ public class ActionFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<IDIYComponent<?>> cloneComponents(List<IDIYComponent<?>> components) {
|
private static List<IDIYComponent<?>> cloneComponents(Collection<IDIYComponent<?>> components) {
|
||||||
List<IDIYComponent<?>> result = new ArrayList<IDIYComponent<?>>(components.size());
|
List<IDIYComponent<?>> result = new ArrayList<IDIYComponent<?>>(components.size());
|
||||||
for (IDIYComponent<?> component : components) {
|
for (IDIYComponent<?> component : components) {
|
||||||
try {
|
try {
|
||||||
@@ -920,6 +926,33 @@ public class ActionFactory {
|
|||||||
plugInPort.rotateSelection(direction);
|
plugInPort.rotateSelection(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MirrorSelectionAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
private int direction;
|
||||||
|
|
||||||
|
public MirrorSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||||
|
super();
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
this.direction = direction;
|
||||||
|
if (direction == ISelectionProcessor.HORIZONTAL) {
|
||||||
|
putValue(AbstractAction.NAME, "Mirror Horizontally");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
|
||||||
|
} else {
|
||||||
|
putValue(AbstractAction.NAME, "Mirror Vertically");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipVertical.getIcon());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info("Mirror Selection triggered: " + direction);
|
||||||
|
plugInPort.mirrorSelection(direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class SendToBackAction extends AbstractAction {
|
public static class SendToBackAction extends AbstractAction {
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.diylc.common.BadPositionException;
|
|||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.common.ISelectionProcessor;
|
||||||
import org.diylc.core.ExpansionMode;
|
import org.diylc.core.ExpansionMode;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Template;
|
import org.diylc.core.Template;
|
||||||
@@ -55,6 +56,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
private JPopupMenu popupMenu;
|
private JPopupMenu popupMenu;
|
||||||
private JMenu selectionMenu;
|
private JMenu selectionMenu;
|
||||||
private JMenu expandMenu;
|
private JMenu expandMenu;
|
||||||
|
private JMenu transformMenu;
|
||||||
private JMenu applyTemplateMenu;
|
private JMenu applyTemplateMenu;
|
||||||
|
|
||||||
private ActionFactory.CutAction cutAction;
|
private ActionFactory.CutAction cutAction;
|
||||||
@@ -72,6 +74,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
private ActionFactory.ExpandSelectionAction expandSelectionSameTypeAction;
|
private ActionFactory.ExpandSelectionAction expandSelectionSameTypeAction;
|
||||||
private ActionFactory.RotateSelectionAction rotateClockwiseAction;
|
private ActionFactory.RotateSelectionAction rotateClockwiseAction;
|
||||||
private ActionFactory.RotateSelectionAction rotateCounterclockwiseAction;
|
private ActionFactory.RotateSelectionAction rotateCounterclockwiseAction;
|
||||||
|
private ActionFactory.MirrorSelectionAction mirrorHorizontallyAction;
|
||||||
|
private ActionFactory.MirrorSelectionAction mirrorVerticallyAction;
|
||||||
|
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
@@ -244,12 +248,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
popupMenu.addSeparator();
|
popupMenu.addSeparator();
|
||||||
popupMenu.add(getEditSelectionAction());
|
popupMenu.add(getEditSelectionAction());
|
||||||
popupMenu.add(getDeleteSelectionAction());
|
popupMenu.add(getDeleteSelectionAction());
|
||||||
popupMenu.add(getRotateClockwiseAction());
|
popupMenu.add(getTransformMenu());
|
||||||
popupMenu.add(getRotateCounterclockwiseAction());
|
|
||||||
popupMenu.add(getGroupAction());
|
|
||||||
popupMenu.add(getUngroupAction());
|
|
||||||
popupMenu.add(getSendToBackAction());
|
|
||||||
popupMenu.add(getBringToFrontAction());
|
|
||||||
popupMenu.add(getSaveAsTemplateAction());
|
popupMenu.add(getSaveAsTemplateAction());
|
||||||
popupMenu.add(getApplyTemplateMenu());
|
popupMenu.add(getApplyTemplateMenu());
|
||||||
popupMenu.add(getExpandMenu());
|
popupMenu.add(getExpandMenu());
|
||||||
@@ -278,6 +277,21 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
return expandMenu;
|
return expandMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JMenu getTransformMenu() {
|
||||||
|
if (transformMenu == null) {
|
||||||
|
transformMenu = new JMenu("Transform Selection");
|
||||||
|
transformMenu.add(getRotateClockwiseAction());
|
||||||
|
transformMenu.add(getRotateCounterclockwiseAction());
|
||||||
|
transformMenu.add(getMirrorHorizontallyAction());
|
||||||
|
transformMenu.add(getMirrorVerticallyAction());
|
||||||
|
transformMenu.add(getGroupAction());
|
||||||
|
transformMenu.add(getUngroupAction());
|
||||||
|
transformMenu.add(getSendToBackAction());
|
||||||
|
transformMenu.add(getBringToFrontAction());
|
||||||
|
}
|
||||||
|
return transformMenu;
|
||||||
|
}
|
||||||
|
|
||||||
public JMenu getApplyTemplateMenu() {
|
public JMenu getApplyTemplateMenu() {
|
||||||
if (applyTemplateMenu == null) {
|
if (applyTemplateMenu == null) {
|
||||||
applyTemplateMenu = new JMenu("Apply Template");
|
applyTemplateMenu = new JMenu("Apply Template");
|
||||||
@@ -384,6 +398,22 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
return rotateCounterclockwiseAction;
|
return rotateCounterclockwiseAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
|
||||||
|
if (mirrorHorizontallyAction == null) {
|
||||||
|
mirrorHorizontallyAction =
|
||||||
|
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL);
|
||||||
|
}
|
||||||
|
return mirrorHorizontallyAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
|
||||||
|
if (mirrorVerticallyAction == null) {
|
||||||
|
mirrorVerticallyAction =
|
||||||
|
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL);
|
||||||
|
}
|
||||||
|
return mirrorVerticallyAction;
|
||||||
|
}
|
||||||
|
|
||||||
public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() {
|
public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() {
|
||||||
if (saveAsTemplateAction == null) {
|
if (saveAsTemplateAction == null) {
|
||||||
saveAsTemplateAction = ActionFactory.getInstance().createSaveAsTemplateAction(plugInPort);
|
saveAsTemplateAction = ActionFactory.getInstance().createSaveAsTemplateAction(plugInPort);
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SELECTION_CHANGED:
|
case SELECTION_CHANGED:
|
||||||
List<IDIYComponent<?>> selection = (List<IDIYComponent<?>>) params[0];
|
Collection<IDIYComponent<?>> selection = (Collection<IDIYComponent<?>>) params[0];
|
||||||
Collection<IDIYComponent<?>> stuckComponents = (Collection<IDIYComponent<?>>) params[1];
|
Collection<IDIYComponent<?>> stuckComponents = (Collection<IDIYComponent<?>>) params[1];
|
||||||
Collection<String> componentNames = new HashSet<String>();
|
Collection<String> componentNames = new HashSet<String>();
|
||||||
for (IDIYComponent<?> component : selection) {
|
for (IDIYComponent<?> component : selection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user