- Timestamp:
- 09/15/15 12:32:33 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/MagneticConstraint/Actions/RepelTextDownAction.java
r962 r963 15 15 public class RepelTextDownAction extends MagneticConstraintAction { 16 16 17 // private void f(final Item item) { 18 // final List<Item> items = item.getParent().getItems(); 19 // for (final Item item2 : items) { 20 // if(item2.getText().compareTo("main") == 0) System.err.println("#Found main"); 21 // } 22 // } 17 public static boolean MergeSameLineParagraphCollisions = false; 23 18 24 19 @Override 25 20 public boolean exec(final Item item) { 26 if(item == null || item.getParent() == null) return false; 27 callback(item); 21 if(item == null || item.getParent() == null) return false; 22 callback(item); 28 23 //Calculate content that needs to be moved to next line. 29 24 //1. Get remainder of line … … 37 32 } 38 33 39 //Move content below this line down40 //1. Get current line & current paragraph.41 34 final Line currentLine = Line.getLineContainingToken(item); 42 35 final Paragraph currentParagraph = Paragraph.getParagraphFromLine(currentLine); 43 //2. Split current paragraph 44 final Point newLineAt = currentParagraph.split(currentLine); 36 final Line nextLine = currentLine.next(); 37 38 final Point newLineAt; 45 39 //Move content contained in 'remainderOfLine' 46 //1. Is remainderOfLine not Empty? 47 if(!remainderOfLine.isEmpty()) { 48 //2a. Yes. Move the content 40 41 42 if(!remainderOfLine.isEmpty() && currentParagraph.contains(nextLine) && MergeSameLineParagraphCollisions) { 43 nextLine.prependLine(remainderOfLine); 44 DisplayIO.setTextCursor((Text) remainderOfLine.getFirst(), Text.HOME); 45 callback(remainderOfLine.getFirst()); 46 FrameIO.SaveFrame(remainderOfLine.getLast().getParent()); 47 } else if(!remainderOfLine.isEmpty()) { 48 newLineAt = currentParagraph.split(currentLine); 49 49 final Point first = remainderOfLine.getBoundingBox().getLocation(); 50 50 for(final Item token : remainderOfLine) { … … 52 52 token.setPosition((float) newX, (float) newLineAt.getY()); 53 53 } 54 //2b. Move the cursor; refresh the screen and use callback to update the magnets55 54 DisplayIO.setTextCursor((Text) remainderOfLine.getFirst(), Text.HOME); 56 callback( null);55 callback(remainderOfLine.getFirst()); 57 56 FrameIO.SaveFrame(remainderOfLine.getLast().getParent()); 58 } else { 59 //3a No. Move the cursor; refresh the screen and use callback to update the magnets 57 }else { 58 //3a No. Move the cursor 59 newLineAt = currentParagraph.split(currentLine); 60 60 DisplayIO.setCursorPosition(newLineAt); 61 61 } 62 62 63 63 return true; 64 64 }
Note:
See TracChangeset
for help on using the changeset viewer.