Changeset 944


Ignore:
Timestamp:
01/13/15 13:55:36 (9 years ago)
Author:
bln4
Message:

The remaining of the implemention of Indirect keyboard and mouse commands

Location:
trunk/src/org/expeditee/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r943 r944  
    6363
    6464        protected FrameKeyboardActions() {
    65                 IndirectKeyboardActions.getInstance().setDropDownAction(new KeyboardAction() {
    66                         @Override
    67                         public void exec(KeyboardInfo info) {
    68                                 // Get the last text item and drop from in
    69                                 Item lastText = null;
    70                                 for (Item i : info.enclosed) {
    71                                         if (i instanceof Text) {
    72                                                 lastText = i;
     65                IndirectKeyboardActions.getInstance().setDropDownAction(
     66                                new KeyboardAction() {
     67                                        @Override
     68                                        public Text exec(final KeyboardInfo info, final char c) {
     69                                                // Get the last text item and drop from in
     70                                                Item lastText = null;
     71                                                for (Item i : info.enclosed) {
     72                                                        if (i instanceof Text) {
     73                                                                lastText = i;
     74                                                        }
     75                                                }
     76                                                // Drop from the item if there was a text item in the
     77                                                // box
     78                                                if (lastText != null) {
     79                                                        Drop(lastText, false);
     80                                                } else {
     81                                                        // Move to the top of the box
     82                                                        Rectangle rect = info.firstConnected
     83                                                                        .getEnclosedShape().getBounds();
     84                                                        int newX = rect.x + Text.MARGIN_LEFT;
     85                                                        int newY = Text.MARGIN_LEFT
     86                                                                        + rect.y
     87                                                                        + DisplayIO.getCurrentFrame()
     88                                                                                        .getItemTemplate()
     89                                                                                        .getBoundsHeight();
     90                                                        moveCursorAndFreeItems(newX, newY);
     91                                                        // TODO can resetOffset be put inside
     92                                                        // moveCursorAndFreeItems
     93                                                        FrameMouseActions.resetOffset();
     94                                                }
     95                                                return null;
    7396                                        }
    74                                 }
    75                                 // Drop from the item if there was a text item in the box
    76                                 if (lastText != null) {
    77                                         Drop(lastText, false);
    78                                 } else {
    79                                         // Move to the top of the box
    80                                         Rectangle rect = info.firstConnected.getEnclosedShape()
    81                                                         .getBounds();
    82                                         int newX = rect.x + Text.MARGIN_LEFT;
    83                                         int newY = Text.MARGIN_LEFT
    84                                                         + rect.y
    85                                                         + DisplayIO.getCurrentFrame().getItemTemplate()
    86                                                                         .getBoundsHeight();
    87                                         moveCursorAndFreeItems(newX, newY);
    88                                         // TODO can resetOffset be put inside
    89                                         // moveCursorAndFreeItems
    90                                         FrameMouseActions.resetOffset();
    91                                 }
    92                         } 
    93                 });
    94                 IndirectKeyboardActions.getInstance().setSizeUpAction(new KeyboardAction() {
    95                         @Override
    96                         public void exec(final KeyboardInfo info) {
    97                                 SetSize(info.firstConnected, info.repeat, false, true, info.isControlDown);
    98                         }               
    99                 });
    100                 IndirectKeyboardActions.getInstance().setSizeDownAction(new KeyboardAction() {
    101                         @Override
    102                         public void exec(final KeyboardInfo info) {
    103                                 SetSize(info.firstConnected, -info.repeat, false, true, info.isControlDown);
    104                         }               
    105                 });
    106                 IndirectKeyboardActions.getInstance().setChangeColorAction(new KeyboardAction() {
    107                         @Override
    108                         public void exec(final KeyboardInfo info) {
    109                                 if (info.connected.size() > 0) {
    110                                         for (Item d : info.lineEnds) {
    111                                                 if (info.isControlDown)
    112                                                         SetGradientColor(d, info.isShiftDown);
    113                                                 else
    114                                                         SetFillColor(d, info.isShiftDown);
    115                                                 break;
     97                                });
     98                IndirectKeyboardActions.getInstance().setSizeUpAction(
     99                                new KeyboardAction() {
     100                                        @Override
     101                                        public Text exec(final KeyboardInfo info, final char c) {
     102                                                SetSize(info.firstConnected, info.repeat, false, true,
     103                                                                info.isControlDown);
     104                                                return null;
    116105                                        }
    117                                 }
    118                         }
    119                 });
     106                                });
     107                IndirectKeyboardActions.getInstance().setSizeDownAction(
     108                                new KeyboardAction() {
     109                                        @Override
     110                                        public Text exec(final KeyboardInfo info, final char c) {
     111                                                SetSize(info.firstConnected, -info.repeat, false, true,
     112                                                                info.isControlDown);
     113                                                return null;
     114                                        }
     115                                });
     116                IndirectKeyboardActions.getInstance().setChangeColorAction(
     117                                new KeyboardAction() {
     118                                        @Override
     119                                        public Text exec(final KeyboardInfo info, final char c) {
     120                                                if (info.connected.size() > 0) {
     121                                                        for (Item d : info.lineEnds) {
     122                                                                if (info.isControlDown)
     123                                                                        SetGradientColor(d, info.isShiftDown);
     124                                                                else
     125                                                                        SetFillColor(d, info.isShiftDown);
     126                                                                break;
     127                                                        }
     128                                                }
     129                                                return null;
     130                                        }
     131                                });
     132                IndirectKeyboardActions.getInstance().setToggleAnnotationAction(
     133                                new KeyboardAction() {
     134                                        @Override
     135                                        public Text exec(final KeyboardInfo info, final char c) {
     136                                                ToggleAnnotation(info.firstConnected);
     137                                                return null;
     138                                        }
     139                                });
     140                IndirectKeyboardActions.getInstance().setChangeFontStyleAction(
     141                                new KeyboardAction() {
     142                                        @Override
     143                                        public Text exec(final KeyboardInfo info, final char c) {
     144                                                ToggleFontStyle(info.firstConnected);
     145                                                return null;
     146                                        }
     147                                });
     148                IndirectKeyboardActions.getInstance().setChangeFontFamilyAction(
     149                                new KeyboardAction() {
     150                                        @Override
     151                                        public Text exec(final KeyboardInfo info, final char c) {
     152                                                ToggleFontFamily(info.firstConnected);
     153                                                return null;
     154                                        }
     155                                });
     156                IndirectKeyboardActions.getInstance().setInsertDateAction(
     157                                new KeyboardAction() {
     158                                        @Override
     159                                        public Text exec(final KeyboardInfo info, final char c) {
     160                                                AddDate(info.firstConnected);
     161                                                return null;
     162                                        }
     163                                });
     164                IndirectKeyboardActions.getInstance().setSaveAction(
     165                                new KeyboardAction() {
     166                                        @Override
     167                                        public Text exec(final KeyboardInfo info, final char c) {
     168                                                Save();
     169                                                return null;
     170                                        }
     171                                });
     172                IndirectKeyboardActions.getInstance().setCreateNewTextAction(
     173                                new KeyboardAction() {
     174                                        @Override
     175                                        public Text exec(KeyboardInfo info, char c) {
     176                                                Text t = DisplayIO.getCurrentFrame().createBlankText(
     177                                                                "" + c);
     178
     179                                                Point2D.Float newMouse = t.insertChar(c,
     180                                                                DisplayIO.getMouseX(), FrameMouseActions.getY());
     181                                                DisplayIO.setCursorPosition(newMouse.x, newMouse.y,
     182                                                                false);
     183
     184                                                return t;
     185                                        }
     186                                });
     187                IndirectKeyboardActions.getInstance().setInsertCharacterAction(
     188                                new KeyboardAction() {
     189                                        @Override
     190                                        public Text exec(final KeyboardInfo info, final char c) {
     191                                                float oldY = FrameMouseActions.MouseY;
     192                                                Point2D.Float newMouse = null;
     193                                                if (c == '\t') {
     194                                                        if (info.isShiftDown) {
     195                                                                newMouse = ((Text)info.firstConnected).removeTab(c, DisplayIO.getFloatMouseX(),
     196                                                                                FrameMouseActions.MouseY);
     197                                                        } else {
     198                                                                newMouse = ((Text)info.firstConnected).insertTab(c, DisplayIO.getFloatMouseX(),
     199                                                                                FrameMouseActions.MouseY);
     200                                                        }
     201                                                } else {
     202                                                        newMouse = ((Text)info.firstConnected).insertChar(c, DisplayIO.getFloatMouseX(),
     203                                                                        FrameMouseActions.MouseY);
     204                                                }
     205                                                /*
     206                                                 * check if the user hit enter and the cursor is now on another text
     207                                                 * item
     208                                                 */
     209                                                if (oldY < newMouse.y) {
     210                                                        // float diff = newMouse.y - oldY;
     211                                                        // System.out.print("c");
     212                                                        Rectangle rect = info.firstConnected.getPolygon().getBounds();
     213
     214                                                        // Text lastEdited = FrameUtils.getLastEdited();
     215                                                        // FrameUtils.setLastEdited(null);
     216
     217                                                        Item justBelow = FrameUtils.onItem(DisplayIO.getCurrentFrame(),
     218                                                                        info.firstConnected.getX() + 10, rect.y + rect.height + 1, false);
     219
     220                                                        // FrameUtils.setLastEdited(lastEdited);
     221
     222                                                        // Dont drop unless
     223                                                        if (justBelow != null && justBelow instanceof Text
     224                                                                        && justBelow != info.firstConnected) {
     225                                                                // Drop all the items below it down!
     226                                                                // Get the list of items that must be dropped
     227                                                                List<Text> column = DisplayIO.getCurrentFrame().getColumn(info.firstConnected);
     228                                                                FrameUtils.Align(column, false, 0);
     229                                                        }
     230                                                }
     231
     232                                                DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false);
     233                                                return (Text) info.firstConnected;
     234                                        }
     235                                });
    120236        }
    121237
     
    185301                        return;
    186302                }
    187                
    188                 if(isShiftDown && MagneticConstraints.getInstance().keyHit(-ch, on)) return;
    189                 else if(MagneticConstraints.getInstance().keyHit(ch, on)) return;
     303
     304                if (isShiftDown && MagneticConstraints.getInstance().keyHit(-ch, on))
     305                        return;
     306                else if (MagneticConstraints.getInstance().keyHit(ch, on))
     307                        return;
    190308
    191309                if (_toRemove != null && on != _toRemove) {
     
    251369                }
    252370
    253                 float oldY = FrameMouseActions.MouseY;
    254 
    255371                DisplayIO.setTextCursor(text, Text.NONE);
    256                 Point2D.Float newMouse = null;
    257                 if (ch == '\t') {
    258                         if (isShiftDown) {
    259                                 newMouse = text.removeTab(ch, DisplayIO.getFloatMouseX(),
    260                                                 FrameMouseActions.MouseY);
    261                         } else {
    262                                 newMouse = text.insertTab(ch, DisplayIO.getFloatMouseX(),
    263                                                 FrameMouseActions.MouseY);
    264                         }
    265                 } else {
    266                         newMouse = text.insertChar(ch, DisplayIO.getFloatMouseX(),
    267                                         FrameMouseActions.MouseY);
    268                 }
    269                 /*
    270                  * check if the user hit enter and the cursor is now on another text
    271                  * item
    272                  */
    273                 if (oldY < newMouse.y) {
    274                         // float diff = newMouse.y - oldY;
    275                         // System.out.print("c");
    276                         Rectangle rect = text.getPolygon().getBounds();
    277 
    278                         // Text lastEdited = FrameUtils.getLastEdited();
    279                         // FrameUtils.setLastEdited(null);
    280 
    281                         Item justBelow = FrameUtils.onItem(DisplayIO.getCurrentFrame(),
    282                                         text.getX() + 10, rect.y + rect.height + 1, false);
    283 
    284                         // FrameUtils.setLastEdited(lastEdited);
    285 
    286                         // Dont drop unless
    287                         if (justBelow != null && justBelow instanceof Text
    288                                         && justBelow != on) {
    289                                 // Drop all the items below it down!
    290                                 // Get the list of items that must be dropped
    291                                 List<Text> column = DisplayIO.getCurrentFrame().getColumn(on);
    292                                 FrameUtils.Align(column, false, 0);
    293                         }
    294                 }
    295 
    296                 DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false);
     372                IndirectKeyboardActions.getInstance().getInsertCharacterAction()
     373                                .exec(new KeyboardInfo(null, ch, isShiftDown, isShiftDown,
     374                                                _enclosedItems, text, _enclosedItems, _enclosedItems), ch);
    297375
    298376                // This repaint is needed for WINDOWS only?!?!? Mike is not sure why!
     
    368446         */
    369447        private static Text createText(char start) {
    370                 Text t = DisplayIO.getCurrentFrame().createBlankText("" + start);
    371 
    372                 Point2D.Float newMouse = t.insertChar(start, DisplayIO.getMouseX(),
    373                                 FrameMouseActions.getY());
    374                 DisplayIO.setCursorPosition(newMouse.x, newMouse.y, false);
    375 
    376                 return t;
     448                return IndirectKeyboardActions.getInstance().getCreateNewTextAction()
     449                                .exec(new KeyboardInfo(null, start, false, false, _enclosedItems, _toRemove, _enclosedItems, _enclosedItems), start);
    377450        }
    378451
     
    461534
    462535                if (keyCode >= KeyEvent.VK_F1 && keyCode <= KeyEvent.VK_F12) {
    463                         functionKey(FunctionKey.values()[keyCode - KeyEvent.VK_F1 + 1], e
    464                                         .isShiftDown(), e.isControlDown());
     536                        functionKey(FunctionKey.values()[keyCode - KeyEvent.VK_F1 + 1],
     537                                        e.isShiftDown(), e.isControlDown());
    465538                        return;
    466539                } else if (e.isAltDown()) {
     
    511584                case KeyEvent.VK_ESCAPE:
    512585                        // Do escape after control so Ctl+Escape does not perform DropDown
    513                         functionKey(FunctionKey.DropDown, e.isShiftDown(), e
    514                                         .isControlDown());
     586                        functionKey(FunctionKey.DropDown, e.isShiftDown(),
     587                                        e.isControlDown());
    515588                        SessionStats.Escape();
    516589                        break;
     
    626699                        // then scroll backup to the title
    627700                        if (textItems.size() > 0) {
    628                                 DisplayIO.MoveCursorToEndOfItem(textItems
    629                                                 .get(textItems.size() - 1));
     701                                DisplayIO
     702                                                .MoveCursorToEndOfItem(textItems.get(textItems.size() - 1));
    630703                        }
    631704                        return;
     
    677750                // add the text of the item to the clipboard
    678751                StringSelection selection = new StringSelection(string);
    679                 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection,
    680                                 null);
     752                Toolkit.getDefaultToolkit().getSystemClipboard()
     753                                .setContents(selection, null);
    681754        }
    682755
     
    848921                        return;
    849922                case KeyEvent.VK_C:
    850                         if(FreeItems.itemsAttachedToCursor()) {
     923                        if (FreeItems.itemsAttachedToCursor()) {
    851924                                ItemSelection.copyClone();
    852925                                return;
    853926                        }
    854                         if(current instanceof Text) {
     927                        if (current instanceof Text) {
    855928                                copyItemToClipboard(current);
    856929                        }
     
    881954                        if (current == null)
    882955                                return;
    883                         if (current != null && !current.hasPermission(UserAppliedPermission.full)) {
     956                        if (current != null
     957                                        && !current.hasPermission(UserAppliedPermission.full)) {
    884958                                MessageBay
    885959                                                .displayMessage("Insufficient permission toggle the items mark");
     
    892966                        break;
    893967                case KeyEvent.VK_Z:
    894                         if(isShiftDown) {
     968                        if (isShiftDown) {
    895969                                DisplayIO.getCurrentFrame().redo();
    896970                        } else {
     
    9561030                         * shortcut for saving a document in most word processors and text
    9571031                         * editors!
    958                          *
    9591032                         */
    9601033                        if (!isShiftDown) {
     
    10451118                                switch (key) {
    10461119                                case DropDown:
    1047                                         IndirectKeyboardActions.getInstance().getDropDownAction().exec(
    1048                                                         new KeyboardInfo(key, repeat, isShiftDown, isControlDown, enclosed, firstConnected, connected, lineEnds));
     1120                                        IndirectKeyboardActions
     1121                                                        .getInstance()
     1122                                                        .getDropDownAction()
     1123                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1124                                                                        isControlDown, enclosed, firstConnected,
     1125                                                                        connected, lineEnds), (char) 0);
    10491126                                        break;
    10501127                                case SizeUp:
    1051                                         IndirectKeyboardActions.getInstance().getSizeUpAction().exec(
    1052                                                         new KeyboardInfo(key, repeat, isShiftDown, isControlDown, enclosed, firstConnected, connected, lineEnds));
     1128                                        IndirectKeyboardActions
     1129                                                        .getInstance()
     1130                                                        .getSizeUpAction()
     1131                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1132                                                                        isControlDown, enclosed, firstConnected,
     1133                                                                        connected, lineEnds), (char) 0);
    10531134                                        break;
    10541135                                case SizeDown:
    1055                                         IndirectKeyboardActions.getInstance().getSizeDownAction().exec(
    1056                                                         new KeyboardInfo(key, repeat, isShiftDown, isControlDown, enclosed, firstConnected, connected, lineEnds));
     1136                                        IndirectKeyboardActions
     1137                                                        .getInstance()
     1138                                                        .getSizeDownAction()
     1139                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1140                                                                        isControlDown, enclosed, firstConnected,
     1141                                                                        connected, lineEnds), (char) 0);
    10571142                                        break;
    10581143                                case ChangeColor:
    1059                                         IndirectKeyboardActions.getInstance().getChangeColorAction().exec(
    1060                                                         new KeyboardInfo(key, repeat, isShiftDown, isControlDown, enclosed, firstConnected, connected, lineEnds));
     1144                                        IndirectKeyboardActions
     1145                                                        .getInstance()
     1146                                                        .getChangeColorAction()
     1147                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1148                                                                        isControlDown, enclosed, firstConnected,
     1149                                                                        connected, lineEnds), (char) 0);
    10611150                                        break;
    10621151                                case ToggleAnnotation:
    1063                                         ToggleAnnotation(firstConnected);
     1152                                        IndirectKeyboardActions
     1153                                                        .getInstance()
     1154                                                        .getToggleAnnotationAction()
     1155                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1156                                                                        isControlDown, enclosed, firstConnected,
     1157                                                                        connected, lineEnds), (char) 0);
    10641158                                        break;
    10651159                                case ChangeFontStyle:
    1066                                         ToggleFontStyle(firstConnected);
     1160                                        IndirectKeyboardActions
     1161                                                        .getInstance()
     1162                                                        .getChangeFontStyleAction()
     1163                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1164                                                                        isControlDown, enclosed, firstConnected,
     1165                                                                        connected, lineEnds), (char) 0);
    10671166                                        break;
    10681167                                case ChangeFontFamily:
    1069                                         ToggleFontFamily(firstConnected);
     1168                                        IndirectKeyboardActions
     1169                                                        .getInstance()
     1170                                                        .getChangeFontFamilyAction()
     1171                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1172                                                                        isControlDown, enclosed, firstConnected,
     1173                                                                        connected, lineEnds), (char) 0);
    10701174                                        break;
    10711175                                case InsertDate:
    1072                                         AddDate(firstConnected);
     1176                                        IndirectKeyboardActions
     1177                                                        .getInstance()
     1178                                                        .getInsertDateAction()
     1179                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1180                                                                        isControlDown, enclosed, firstConnected,
     1181                                                                        connected, lineEnds), (char) 0);
    10731182                                        break;
    10741183                                case Save:
    1075                                         Save();
     1184                                        IndirectKeyboardActions
     1185                                                        .getInstance()
     1186                                                        .getSaveAction()
     1187                                                        .exec(new KeyboardInfo(key, repeat, isShiftDown,
     1188                                                                        isControlDown, enclosed, firstConnected,
     1189                                                                        connected, lineEnds), (char) 0);
    10761190                                        MessageBay.displayMessage(displayMessage);
    10771191                                        break;
     
    10971211                                FrameKeyboardActions.Refresh();
    10981212                                return;
    1099 //                              if (isControlDown) {
    1100 //                                      UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() - 0.05f);
    1101 //                                      Misc.repaint();
    1102 //                                      return;
    1103 //                              }
     1213                                // if (isControlDown) {
     1214                                // UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() -
     1215                                // 0.05f);
     1216                                // Misc.repaint();
     1217                                // return;
     1218                                // }
    11041219                        case SizeUp:
    11051220                                zoomFrame(DisplayIO.getCurrentFrame(), 1.1f);
     
    11071222                                FrameKeyboardActions.Refresh();
    11081223                                return;
    1109 //                              if (isControlDown) {
    1110 //                                      UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() + 0.05f);
    1111 //                                      Misc.repaint();
    1112 //                                      return;
    1113 //                              }
     1224                                // if (isControlDown) {
     1225                                // UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() +
     1226                                // 0.05f);
     1227                                // Misc.repaint();
     1228                                // return;
     1229                                // }
    11141230                        default:
    11151231                                MessageBay.displayMessageOnce(displayMessage);
     
    13391455
    13401456                                                // Add previous button to the new frame
    1341                                                 frameCreator.addPreviousButton(moreFrame, firstFrame
    1342                                                                 .getName());
     1457                                                frameCreator.addPreviousButton(moreFrame,
     1458                                                                firstFrame.getName());
    13431459                                                Item first = current.getAnnotation("first");
    13441460                                                if (first != null) {
    1345                                                         frameCreator.addFirstButton(moreFrame, first
    1346                                                                         .getLink());
     1461                                                        frameCreator.addFirstButton(moreFrame,
     1462                                                                        first.getLink());
    13471463                                                } else {
    1348                                                         frameCreator.addFirstButton(moreFrame, firstFrame
    1349                                                                         .getName());
     1464                                                        frameCreator.addFirstButton(moreFrame,
     1465                                                                        firstFrame.getName());
    13501466                                                }
    13511467                                                // Add the @next if we are pasting
     
    13611477                                                if (!mouseMoved) {
    13621478                                                        Item moreTitle = moreFrame.getTitleItem();
    1363                                                         moreTitle.setOverlayPermission(UserAppliedPermission.full);
     1479                                                        moreTitle
     1480                                                                        .setOverlayPermission(UserAppliedPermission.full);
    13641481                                                        Drop(moreTitle, bPasting);
    13651482                                                }
     
    15921709                return newItemText;
    15931710        }
    1594        
     1711
    15951712        private static boolean refreshAnchors(Collection<Item> items) {
    15961713                boolean bReparse = false;
    1597                
    1598                 for(Item i : items) {
    1599                         Float anchorLeft   = i.getAnchorLeft();
    1600                         Float anchorRight  = i.getAnchorRight();
    1601                         Float anchorTop    = i.getAnchorTop();
     1714
     1715                for (Item i : items) {
     1716                        Float anchorLeft = i.getAnchorLeft();
     1717                        Float anchorRight = i.getAnchorRight();
     1718                        Float anchorTop = i.getAnchorTop();
    16021719                        Float anchorBottom = i.getAnchorBottom();
    1603        
    1604                        
     1720
    16051721                        if (anchorLeft != null) {
    16061722                                i.setAnchorLeft(anchorLeft);
     
    16091725                                }
    16101726                        }
    1611                        
     1727
    16121728                        if (anchorRight != null) {
    16131729                                i.setAnchorRight(anchorRight);
     
    16161732                                }
    16171733                        }
    1618                        
     1734
    16191735                        if (anchorTop != null) {
    16201736                                i.setAnchorTop(anchorTop);
     
    16231739                                }
    16241740                        }
    1625                        
     1741
    16261742                        if (anchorBottom != null) {
    16271743                                i.setAnchorBottom(anchorBottom);
     
    16331749                return bReparse;
    16341750        }
    1635        
     1751
    16361752        public static void zoomFrame(Frame frame, double scaleFactor) {
    1637                
     1753
    16381754                int x = FrameMouseActions.getX(), y = FrameMouseActions.getY();
    1639                
     1755
    16401756                if (frame == null) {
    16411757                        return;
    16421758                }
    1643                
     1759
    16441760                Collection<Item> items = frame.getVisibleItems();
    1645                
    1646                 for(Item item : items) {
    1647                         if(item instanceof Text && item.getSize() <= Text.MINIMUM_FONT_SIZE && scaleFactor < 1) {
     1761
     1762                for (Item item : items) {
     1763                        if (item instanceof Text
     1764                                        && item.getSize() <= Text.MINIMUM_FONT_SIZE
     1765                                        && scaleFactor < 1) {
    16481766                                return;
    16491767                        }
    16501768                }
    1651                
     1769
    16521770                for (Vector v : frame.getVectors()) {
    16531771                        v.Source.scale((float) scaleFactor, x, y);
    16541772                }
    1655                
     1773
    16561774                for (Item item : items) {
    16571775                        // This line is only needed for circles!!
     
    17131831                        if (item.isFrameName()) {
    17141832                                // scale the entire frame
    1715                                 if(diff != 0) {
    1716                                         zoomFrame(DisplayIO.getCurrentFrame(), diff > 0 ? 1.1 : 0.909090909);
     1833                                if (diff != 0) {
     1834                                        zoomFrame(DisplayIO.getCurrentFrame(), diff > 0 ? 1.1
     1835                                                        : 0.909090909);
    17171836                                        DisplayIO.getCurrentFrame().refreshSize();
    17181837                                        FrameKeyboardActions.Refresh();
     
    17511870
    17521871                        }// Enclosed circle centers are resized with the center as origin
    1753                         // Just add the circle center to the list of items to size
     1872                                // Just add the circle center to the list of items to size
    17541873                        else if (!toSet.hasEnclosures() && !(toSet instanceof Text)
    17551874                                        && toSet.isLineEnd()) {
     
    17751894                        }
    17761895                }
    1777                
     1896
    17781897                // add widgets to notify
    1779                 for(Item i : toSize) {
    1780                         if(i instanceof WidgetEdge) {
     1898                for (Item i : toSize) {
     1899                        if (i instanceof WidgetEdge) {
    17811900                                widgets.add(((WidgetEdge) i).getWidgetSource());
    1782                         } else if(i instanceof WidgetCorner) {
     1901                        } else if (i instanceof WidgetCorner) {
    17831902                                widgets.add(((WidgetCorner) i).getWidgetSource());
    17841903                        }
     
    18281947                                        assert (i instanceof Text);
    18291948                                        Text text = (Text) i;
    1830                                         AttributeValuePair avp = new AttributeValuePair(text
    1831                                                         .getText());
     1949                                        AttributeValuePair avp = new AttributeValuePair(
     1950                                                        text.getText());
    18321951                                        double scale = 1F;
    18331952                                        try {
     
    18451964                        }
    18461965                        // refresh anchored items
    1847                 if(refreshAnchors(toSize)) {
    1848                         FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
    1849                 }
     1966                        if (refreshAnchors(toSize)) {
     1967                                FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
     1968                        }
    18501969                        // notify widgets they were resized
    1851                         for(InteractiveWidget iw : widgets) {
     1970                        for (InteractiveWidget iw : widgets) {
    18521971                                iw.onResized();
    18531972                        }
     
    19082027                if (toSet != null)
    19092028                        toSet.getParent().setChanged(true);
    1910                
     2029
    19112030                // refresh anchored items
    1912                 if(refreshAnchors(toSize)) {
     2031                if (refreshAnchors(toSize)) {
    19132032                        FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
    19142033                }
    19152034
    19162035                // notify widgets they were resized
    1917                 for(InteractiveWidget iw : widgets) {
     2036                for (InteractiveWidget iw : widgets) {
    19182037                        iw.onResized();
    19192038                }
     
    19512070                        color = null;
    19522071                else
    1953                         color = ColorUtils.getNextColor(color, TemplateSettings.FillColorWheel.get(), toSet
    1954                                         .getGradientColor());
     2072                        color = ColorUtils.getNextColor(color,
     2073                                        TemplateSettings.FillColorWheel.get(),
     2074                                        toSet.getGradientColor());
    19552075
    19562076                // if (color == null) {
     
    19792099                        color = null;
    19802100                else
    1981                         color = ColorUtils.getNextColor(color, TemplateSettings.ColorWheel.get(), toSet
    1982                                         .getFillColor());
     2101                        color = ColorUtils.getNextColor(color,
     2102                                        TemplateSettings.ColorWheel.get(), toSet.getFillColor());
    19832103
    19842104                // if (color == null) {
     
    20602180                        color = null;
    20612181                else if (setBackgroundColor) {
    2062                         color = ColorUtils.getNextColor(color, TemplateSettings.FillColorWheel.get(), item
    2063                                         .getPaintColor());
     2182                        color = ColorUtils
     2183                                        .getNextColor(color, TemplateSettings.FillColorWheel.get(),
     2184                                                        item.getPaintColor());
    20642185                } else {
    2065                         color = ColorUtils.getNextColor(color, TemplateSettings.ColorWheel.get(),
     2186                        color = ColorUtils.getNextColor(color,
     2187                                        TemplateSettings.ColorWheel.get(),
    20662188                                        currentFrame.getPaintBackgroundColor());
    20672189                }
     
    23192441        public static void Refresh() {
    23202442                Frame currentFrame = DisplayIO.getCurrentFrame();
    2321                
    2322                 if(FrameMouseActions.isShiftDown()) {
     2443
     2444                if (FrameMouseActions.isShiftDown()) {
    23232445                        currentFrame.refreshSize();
    23242446                }
  • trunk/src/org/expeditee/gui/indirect/keyboard/IndirectKeyboardActions.java

    r943 r944  
    66                //Function Keys
    77                DropDown, SizeUp, SizeDown, ChangeColor, ToggleAnnotation, InsertDate, NewFrameset, ChangeFontStyle, ChangeFontFamily,
    8                 AudienceMode, XRayMode, Save, Refresh
     8                AudienceMode, XRayMode, Save, Refresh,
     9                //Process character
     10                NewText, InsertCharacter
    911        }
    1012       
     
    5759        public KeyboardAction getRefreshAction() { return actions[Action.Refresh.ordinal()]; }
    5860        public KeyboardAction setRefreshAction(final KeyboardAction action) { actions[Action.Refresh.ordinal()] = action; return action; }
     61
     62        public KeyboardAction getCreateNewTextAction() { return actions[Action.NewText.ordinal()]; }
     63        public KeyboardAction setCreateNewTextAction(final KeyboardAction action) { actions[Action.NewText.ordinal()] = action; return action; }
     64       
     65        public KeyboardAction getInsertCharacterAction() { return actions[Action.InsertCharacter.ordinal()]; }
     66        public KeyboardAction setInsertCharacterAction(final KeyboardAction action) { actions[Action.InsertCharacter.ordinal()] = action; return action; }
    5967}
  • trunk/src/org/expeditee/gui/indirect/keyboard/KeyboardAction.java

    r943 r944  
    55import org.expeditee.gui.FunctionKey;
    66import org.expeditee.items.Item;
     7import org.expeditee.items.Text;
    78
    89public interface KeyboardAction {
    9         public void exec(final KeyboardInfo info);
     10        public Text exec(final KeyboardInfo info, char c);
    1011
    1112        public class KeyboardInfo {
Note: See TracChangeset for help on using the changeset viewer.