mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Ability to rotate selection
This commit is contained in:
+22
-16
@@ -15,24 +15,30 @@ import javax.swing.ImageIcon;
|
||||
*/
|
||||
public enum IconLoader {
|
||||
|
||||
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage("garbage.png"), DiskBlue(
|
||||
"disk_blue.png"), SaveAs("save_as.png"), Exit("exit.png"), DocumentPlainYellow(
|
||||
"document_plain_yellow.png"), PhotoScenery("photo_scenery.png"), LightBulbOn(
|
||||
"lightbulb_on.png"), LightBulbOff("lightbulb_off.png"), NotebookAdd("notebook_add.png"), FormGreen(
|
||||
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage(
|
||||
"garbage.png"), DiskBlue("disk_blue.png"), SaveAs("save_as.png"), Exit(
|
||||
"exit.png"), DocumentPlainYellow("document_plain_yellow.png"), PhotoScenery(
|
||||
"photo_scenery.png"), LightBulbOn("lightbulb_on.png"), LightBulbOff(
|
||||
"lightbulb_off.png"), NotebookAdd("notebook_add.png"), FormGreen(
|
||||
"form_green.png"), Gears("gears.png"), About("about.png"), WindowColors(
|
||||
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck("navigate_check.png"), Undo(
|
||||
"undo.png"), Error("error.png"), Warning("warning.png"), ZoomSmall("zoom_small.png"), MoveSmall(
|
||||
"move_small.png"), Print("print.png"), PDF("pdf.png"), Excel("excel.png"), CSV(
|
||||
"csv.png"), HTML("html.png"), Image("image.png"), Cut("cut.png"), Copy("copy.png"), Paste(
|
||||
"paste.png"), Selection("selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
|
||||
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload("upload.png"), Wrench(
|
||||
"wrench.png"), Group("group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq(
|
||||
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
||||
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck(
|
||||
"navigate_check.png"), Undo("undo.png"), Error("error.png"), Warning(
|
||||
"warning.png"), ZoomSmall("zoom_small.png"), MoveSmall(
|
||||
"move_small.png"), Print("print.png"), PDF("pdf.png"), Excel(
|
||||
"excel.png"), CSV("csv.png"), HTML("html.png"), Image("image.png"), Cut(
|
||||
"cut.png"), Copy("copy.png"), Paste("paste.png"), Selection(
|
||||
"selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
|
||||
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload(
|
||||
"upload.png"), Wrench("wrench.png"), Group("group.png"), Ungroup(
|
||||
"ungroup.png"), TraceMask("trace_mask.png"), Faq("faq.png"), Component(
|
||||
"component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens(
|
||||
"pens.png"), Sort("sort.png"), ElementsSelection("elements_selection.png"), BranchAdd(
|
||||
"branch_add.png"), Briefcase_Add("briefcase_add.png");
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit(
|
||||
"document_edit.png"), EditComponent("edit_component.png"), Size(
|
||||
"size.png"), Front("front.png"), Back("back.png"), Pens("pens.png"), Sort(
|
||||
"sort.png"), ElementsSelection("elements_selection.png"), BranchAdd(
|
||||
"branch_add.png"), Briefcase_Add("briefcase_add.png"), RotateCW(
|
||||
"rotate_cw.png"), RotateCCW("rotate_ccw.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 760 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 760 B |
+38
@@ -142,6 +142,11 @@ public class ActionFactory {
|
||||
return new ExpandSelectionAction(plugInPort, expansionMode);
|
||||
}
|
||||
|
||||
public RotateSelectionAction createRotateSelectionAction(
|
||||
IPlugInPort plugInPort, int direction) {
|
||||
return new RotateSelectionAction(plugInPort, direction);
|
||||
}
|
||||
|
||||
public SendToBackAction createSendToBackAction(IPlugInPort plugInPort) {
|
||||
return new SendToBackAction(plugInPort);
|
||||
}
|
||||
@@ -871,6 +876,39 @@ public class ActionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static class RotateSelectionAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private int direction;
|
||||
|
||||
public RotateSelectionAction(IPlugInPort plugInPort, int direction) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.direction = direction;
|
||||
if (direction > 0) {
|
||||
putValue(AbstractAction.NAME, "Rotate Clockwise");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.RotateCW
|
||||
.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke
|
||||
.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK));
|
||||
} else {
|
||||
putValue(AbstractAction.NAME, "Rotate Counterclockwise");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.RotateCCW
|
||||
.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke
|
||||
.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Rotate Selection triggered: " + direction);
|
||||
plugInPort.rotateSelection(direction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SendToBackAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+18
@@ -67,6 +67,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionAllAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionImmediateAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionSameTypeAction;
|
||||
private ActionFactory.RotateSelectionAction rotateClockwiseAction;
|
||||
private ActionFactory.RotateSelectionAction rotateCounterclockwiseAction;
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private ISwingUI swingUI;
|
||||
@@ -246,6 +248,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(getEditSelectionAction());
|
||||
popupMenu.add(getDeleteSelectionAction());
|
||||
popupMenu.add(getRotateClockwiseAction());
|
||||
popupMenu.add(getRotateCounterclockwiseAction());
|
||||
popupMenu.add(getGroupAction());
|
||||
popupMenu.add(getUngroupAction());
|
||||
popupMenu.add(getSendToBackAction());
|
||||
@@ -337,6 +341,20 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
}
|
||||
return deleteSelectionAction;
|
||||
}
|
||||
|
||||
public ActionFactory.RotateSelectionAction getRotateClockwiseAction() {
|
||||
if (rotateClockwiseAction == null) {
|
||||
rotateClockwiseAction = ActionFactory.getInstance().createRotateSelectionAction(plugInPort, 1);
|
||||
}
|
||||
return rotateClockwiseAction;
|
||||
}
|
||||
|
||||
public ActionFactory.RotateSelectionAction getRotateCounterclockwiseAction() {
|
||||
if (rotateCounterclockwiseAction == null) {
|
||||
rotateCounterclockwiseAction = ActionFactory.getInstance().createRotateSelectionAction(plugInPort, -1);
|
||||
}
|
||||
return rotateCounterclockwiseAction;
|
||||
}
|
||||
|
||||
public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() {
|
||||
if (saveAsTemplateAction == null) {
|
||||
|
||||
+71
-30
@@ -45,6 +45,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionImmediateAction;
|
||||
private ActionFactory.ExpandSelectionAction expandSelectionSameTypeAction;
|
||||
private ActionFactory.SaveAsTemplateAction saveAsTemplateAction;
|
||||
private ActionFactory.RotateSelectionAction rotateClockwiseAction;
|
||||
private ActionFactory.RotateSelectionAction rotateCounterClockwiseAction;
|
||||
|
||||
private UndoHandler<Project> undoHandler;
|
||||
|
||||
@@ -77,64 +79,72 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
public ActionFactory.CutAction getCutAction() {
|
||||
if (cutAction == null) {
|
||||
cutAction = ActionFactory.getInstance().createCutAction(plugInPort, clipboard, this);
|
||||
cutAction = ActionFactory.getInstance().createCutAction(plugInPort,
|
||||
clipboard, this);
|
||||
}
|
||||
return cutAction;
|
||||
}
|
||||
|
||||
public ActionFactory.CopyAction getCopyAction() {
|
||||
if (copyAction == null) {
|
||||
copyAction = ActionFactory.getInstance().createCopyAction(plugInPort, clipboard, this);
|
||||
copyAction = ActionFactory.getInstance().createCopyAction(
|
||||
plugInPort, clipboard, this);
|
||||
}
|
||||
return copyAction;
|
||||
}
|
||||
|
||||
public ActionFactory.PasteAction getPasteAction() {
|
||||
if (pasteAction == null) {
|
||||
pasteAction = ActionFactory.getInstance().createPasteAction(plugInPort, clipboard);
|
||||
pasteAction = ActionFactory.getInstance().createPasteAction(
|
||||
plugInPort, clipboard);
|
||||
}
|
||||
return pasteAction;
|
||||
}
|
||||
|
||||
public ActionFactory.EditSelectionAction getEditSelectionAction() {
|
||||
if (editSelectionAction == null) {
|
||||
editSelectionAction = ActionFactory.getInstance().createEditSelectionAction(plugInPort);
|
||||
editSelectionAction = ActionFactory.getInstance()
|
||||
.createEditSelectionAction(plugInPort);
|
||||
}
|
||||
return editSelectionAction;
|
||||
}
|
||||
|
||||
public ActionFactory.DeleteSelectionAction getDeleteSelectionAction() {
|
||||
if (deleteSelectionAction == null) {
|
||||
deleteSelectionAction = ActionFactory.getInstance().createDeleteSelectionAction(
|
||||
plugInPort);
|
||||
deleteSelectionAction = ActionFactory.getInstance()
|
||||
.createDeleteSelectionAction(plugInPort);
|
||||
}
|
||||
return deleteSelectionAction;
|
||||
}
|
||||
|
||||
public ActionFactory.GroupAction getGroupAction() {
|
||||
if (groupAction == null) {
|
||||
groupAction = ActionFactory.getInstance().createGroupAction(plugInPort);
|
||||
groupAction = ActionFactory.getInstance().createGroupAction(
|
||||
plugInPort);
|
||||
}
|
||||
return groupAction;
|
||||
}
|
||||
|
||||
public ActionFactory.UngroupAction getUngroupAction() {
|
||||
if (ungroupAction == null) {
|
||||
ungroupAction = ActionFactory.getInstance().createUngroupAction(plugInPort);
|
||||
ungroupAction = ActionFactory.getInstance().createUngroupAction(
|
||||
plugInPort);
|
||||
}
|
||||
return ungroupAction;
|
||||
}
|
||||
|
||||
public ActionFactory.SendToBackAction getSendToBackAction() {
|
||||
if (sendToBackAction == null) {
|
||||
sendToBackAction = ActionFactory.getInstance().createSendToBackAction(plugInPort);
|
||||
sendToBackAction = ActionFactory.getInstance()
|
||||
.createSendToBackAction(plugInPort);
|
||||
}
|
||||
return sendToBackAction;
|
||||
}
|
||||
|
||||
public ActionFactory.BringToFrontAction getBringToFrontAction() {
|
||||
if (bringToFrontAction == null) {
|
||||
bringToFrontAction = ActionFactory.getInstance().createBringToFrontAction(plugInPort);
|
||||
bringToFrontAction = ActionFactory.getInstance()
|
||||
.createBringToFrontAction(plugInPort);
|
||||
}
|
||||
return bringToFrontAction;
|
||||
}
|
||||
@@ -149,43 +159,62 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
public ActionFactory.RenumberAction getRenumberYAxisAction() {
|
||||
if (renumberYAxisAction == null) {
|
||||
renumberYAxisAction = ActionFactory.getInstance().createRenumberAction(plugInPort,
|
||||
false);
|
||||
renumberYAxisAction = ActionFactory.getInstance()
|
||||
.createRenumberAction(plugInPort, false);
|
||||
}
|
||||
return renumberYAxisAction;
|
||||
}
|
||||
|
||||
public ActionFactory.ExpandSelectionAction getExpandSelectionAllAction() {
|
||||
if (expandSelectionAllAction == null) {
|
||||
expandSelectionAllAction = ActionFactory.getInstance().createExpandSelectionAction(
|
||||
plugInPort, ExpansionMode.ALL);
|
||||
expandSelectionAllAction = ActionFactory.getInstance()
|
||||
.createExpandSelectionAction(plugInPort, ExpansionMode.ALL);
|
||||
}
|
||||
return expandSelectionAllAction;
|
||||
}
|
||||
|
||||
public ActionFactory.ExpandSelectionAction getExpandSelectionImmediateAction() {
|
||||
if (expandSelectionImmediateAction == null) {
|
||||
expandSelectionImmediateAction = ActionFactory.getInstance().createExpandSelectionAction(
|
||||
plugInPort, ExpansionMode.IMMEDIATE);
|
||||
expandSelectionImmediateAction = ActionFactory.getInstance()
|
||||
.createExpandSelectionAction(plugInPort,
|
||||
ExpansionMode.IMMEDIATE);
|
||||
}
|
||||
return expandSelectionImmediateAction;
|
||||
}
|
||||
|
||||
public ActionFactory.ExpandSelectionAction getExpandSelectionSameTypeAction() {
|
||||
if (expandSelectionSameTypeAction == null) {
|
||||
expandSelectionSameTypeAction = ActionFactory.getInstance().createExpandSelectionAction(
|
||||
plugInPort, ExpansionMode.SAME_TYPE);
|
||||
expandSelectionSameTypeAction = ActionFactory.getInstance()
|
||||
.createExpandSelectionAction(plugInPort,
|
||||
ExpansionMode.SAME_TYPE);
|
||||
}
|
||||
return expandSelectionSameTypeAction;
|
||||
}
|
||||
|
||||
|
||||
public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() {
|
||||
if (saveAsTemplateAction == null) {
|
||||
saveAsTemplateAction = ActionFactory.getInstance().createSaveAsTemplateAction(plugInPort);
|
||||
saveAsTemplateAction = ActionFactory.getInstance()
|
||||
.createSaveAsTemplateAction(plugInPort);
|
||||
}
|
||||
return saveAsTemplateAction;
|
||||
}
|
||||
|
||||
public ActionFactory.RotateSelectionAction getRotateClockwiseAction() {
|
||||
if (rotateClockwiseAction == null) {
|
||||
rotateClockwiseAction = ActionFactory.getInstance()
|
||||
.createRotateSelectionAction(plugInPort, 1);
|
||||
}
|
||||
return rotateClockwiseAction;
|
||||
}
|
||||
|
||||
public ActionFactory.RotateSelectionAction getRotateCounterclockwiseAction() {
|
||||
if (rotateCounterClockwiseAction == null) {
|
||||
rotateCounterClockwiseAction = ActionFactory.getInstance()
|
||||
.createRotateSelectionAction(plugInPort, -1);
|
||||
}
|
||||
return rotateCounterClockwiseAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
@@ -199,31 +228,40 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
swingUI.injectMenuAction(getCopyAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getPasteAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createSelectAllAction(plugInPort), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory
|
||||
.createSelectAllAction(plugInPort), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getEditSelectionAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getDeleteSelectionAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRotateClockwiseAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRotateCounterclockwiseAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getGroupAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getUngroupAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getSendToBackAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getBringToFrontAction(), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getSaveAsTemplateAction(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(RENUMBER_TITLE, IconLoader.Sort.getIcon(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(RENUMBER_TITLE, IconLoader.Sort.getIcon(),
|
||||
EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberXAxisAction(), RENUMBER_TITLE);
|
||||
swingUI.injectMenuAction(getRenumberYAxisAction(), RENUMBER_TITLE);
|
||||
swingUI.injectSubmenu(EXPAND_TITLE, IconLoader.BranchAdd.getIcon(), EDIT_TITLE);
|
||||
swingUI.injectSubmenu(EXPAND_TITLE, IconLoader.BranchAdd.getIcon(),
|
||||
EDIT_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionAllAction(), EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionImmediateAction(), EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionSameTypeAction(), EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionImmediateAction(),
|
||||
EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(getExpandSelectionSameTypeAction(),
|
||||
EXPAND_TITLE);
|
||||
swingUI.injectMenuAction(null, EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory.createEditProjectAction(plugInPort), EDIT_TITLE);
|
||||
swingUI.injectMenuAction(actionFactory
|
||||
.createEditProjectAction(plugInPort), EDIT_TITLE);
|
||||
|
||||
refreshActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED, EventType.PROJECT_MODIFIED);
|
||||
return EnumSet.of(EventType.SELECTION_CHANGED,
|
||||
EventType.PROJECT_MODIFIED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -233,7 +271,8 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
refreshActions();
|
||||
break;
|
||||
case PROJECT_MODIFIED:
|
||||
undoHandler.stateChanged((Project) params[0], (Project) params[1], (String) params[2]);
|
||||
undoHandler.stateChanged((Project) params[0], (Project) params[1],
|
||||
(String) params[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -243,8 +282,10 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
getCutAction().setEnabled(enabled);
|
||||
getCopyAction().setEnabled(enabled);
|
||||
try {
|
||||
getPasteAction().setEnabled(
|
||||
clipboard.isDataFlavorAvailable(ComponentTransferable.listFlavor));
|
||||
getPasteAction()
|
||||
.setEnabled(
|
||||
clipboard
|
||||
.isDataFlavorAvailable(ComponentTransferable.listFlavor));
|
||||
} catch (Exception e) {
|
||||
getPasteAction().setEnabled(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user