Skip to content

Commit

Permalink
Development Backup 15
Browse files Browse the repository at this point in the history
-The Editor's done! I might reorganize a bit more here and there before
final commit, but functionally everything's online and ready for action.
Turning my attention now to the last thing that needs work,
SentenceMaker.
  • Loading branch information
barrowclift committed Sep 4, 2013
1 parent 788fed5 commit f87b363
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 235 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.drexel.psal.anonymouth.gooie;
package edu.drexel.psal.anonymouth.engine;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -13,9 +13,12 @@
import com.jgaap.generics.Document;

import edu.drexel.psal.ANONConstants;
import edu.drexel.psal.anonymouth.engine.DataAnalyzer;
import edu.drexel.psal.anonymouth.engine.DocumentMagician;
import edu.drexel.psal.anonymouth.engine.FeatureList;
import edu.drexel.psal.anonymouth.gooie.ClustersDriver;
import edu.drexel.psal.anonymouth.gooie.DictionaryBinding;
import edu.drexel.psal.anonymouth.gooie.EditorDriver;
import edu.drexel.psal.anonymouth.gooie.GUIMain;
import edu.drexel.psal.anonymouth.gooie.ProgressWindow;
import edu.drexel.psal.anonymouth.gooie.ThePresident;
import edu.drexel.psal.anonymouth.helpers.ErrorHandler;
import edu.drexel.psal.anonymouth.utils.ConsolidationStation;
import edu.drexel.psal.anonymouth.utils.FunctionWords;
Expand Down Expand Up @@ -74,7 +77,7 @@ protected Void doInBackground() throws Exception {
* The process call that any outside class should call when we want to
* process.
*/
protected void process() {
public void process() {
this.editorDriver = main.editorDriver;
readyProcessingThread();
processing.execute();
Expand Down
49 changes: 32 additions & 17 deletions src/edu/drexel/psal/anonymouth/engine/VersionControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.util.Stack;

import edu.drexel.psal.anonymouth.gooie.EditorDriver;
import edu.drexel.psal.anonymouth.gooie.MenuDriver;
import edu.drexel.psal.anonymouth.gooie.GUIMain;
import edu.drexel.psal.anonymouth.utils.TaggedDocument;
import edu.drexel.psal.jstylo.generics.Logger;

/**
* Adds undo/redo functionality to the documents pane.
Expand All @@ -14,6 +14,7 @@
*/
public class VersionControl {

private final String NAME = "( " + this.getClass().getSimpleName() + " ) - ";
/**
* The absolute max allowed stack size for ether undo or redo.<br><br>
*
Expand Down Expand Up @@ -71,8 +72,6 @@ public VersionControl(GUIMain main) {
public void init() {
editor = main.editorDriver;
pastTaggedDoc = new TaggedDocument(editor.taggedDoc);
addVersion(pastTaggedDoc, editor.priorCaretPosition);
pastTaggedDoc = new TaggedDocument(editor.taggedDoc);
}

/**
Expand Down Expand Up @@ -127,11 +126,19 @@ public void updateUndoRedo(TaggedDocument taggedDoc, int priorCaretPosition, boo
* The position the caret was at for this particular backup
*/
private void addVersion(TaggedDocument taggedDoc, int priorCaretPosition) {
Logger.logln(NAME+"A new backup has been added to the Undo stack");
ready = false;
if (undo.size() >= SIZECAP) {
undo.remove(0);
}

if (redo.size() == 0) {
main.enableRedo(false);
}
if (undo.size() == 0) {
main.enableUndo(false);
}

taggedDoc.clearAllTranslations();
undo.push(new TaggedDocument(taggedDoc));
indicesUndo.push(priorCaretPosition);
Expand All @@ -153,10 +160,11 @@ private void addVersion(TaggedDocument taggedDoc, int priorCaretPosition) {
* the redo one.
*/
public void undo() {
Logger.logln(NAME+"UNDO ----------------------------------");
ready = false;

redo.push(new TaggedDocument(editor.taggedDoc));
indicesRedo.push(main.documentPane.getCaret().getDot());
indicesRedo.push(editor.newCaretPosition[0]);

editor.taggedDoc = undo.pop();
editor.newCaretPosition[0] = indicesUndo.pop();
Expand All @@ -165,15 +173,18 @@ public void undo() {

main.enableRedo(true);

if (redo.size() == 0) {
main.enableRedo(false);
}
if (undo.size() == 0) {
main.enableUndo(false);
}

synchronized(MenuDriver.class) {
//set ready flag to true (so isReady returns true)
ready = true;
MenuDriver.class.notifyAll();
}
// synchronized(MenuDriver.class) {
// //set ready flag to true (so isReady returns true)
// ready = true;
// MenuDriver.class.notifyAll();
// }
}

/**
Expand All @@ -185,26 +196,30 @@ public void undo() {
* the undo one.
*/
public void redo() {
Logger.logln(NAME+"REDO ----------------------------------");
ready = false;

undo.push(new TaggedDocument(editor.taggedDoc));
indicesUndo.push(main.documentPane.getCaret().getDot());
indicesUndo.push(editor.newCaretPosition[0]);

editor.taggedDoc = redo.pop();
editor.newCaretPosition[0] = indicesUndo.pop();
editor.newCaretPosition[0] = editor.newCaretPosition[0];
editor.newCaretPosition[0] = indicesRedo.pop();
editor.newCaretPosition[1] = editor.newCaretPosition[0];
editor.syncTextPaneWithTaggedDoc();

main.enableUndo(true);

if (redo.size() == 0) {
main.enableRedo(false);
}

synchronized(MenuDriver.class) {
//set ready flag to true (so isReady returns true)
ready = true;
MenuDriver.class.notifyAll();
if (undo.size() == 0) {
main.enableUndo(false);
}

// synchronized(MenuDriver.class) {
// //set ready flag to true (so isReady returns true)
// ready = true;
// MenuDriver.class.notifyAll();
// }
}
}
4 changes: 2 additions & 2 deletions src/edu/drexel/psal/anonymouth/gooie/AnonymityBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public AnonymityBar(GUIMain main) {
* @param show
* Whether or not you want the bar's fill to be visible
*/
protected void showFill(boolean show) {
public void showFill(boolean show) {
showFill = show;
repaint(); //no variables to update, just paint the fill
}
Expand All @@ -331,7 +331,7 @@ protected void showFill(boolean show) {
* The value you want the bar to treat as the max, basically as the
* "100" in 0-100%.
*/
protected void setMaxFill(double maxPercent) {
public void setMaxFill(double maxPercent) {
maxFill = (float)maxPercent;
}

Expand Down
Loading

0 comments on commit f87b363

Please sign in to comment.