Search in sources :

Example 6 with Grouping

use of doc.mathobjects.Grouping in project OpenNotebook by jaltekruse.

the class Document method generateNewVersion.

public boolean generateNewVersion() {
    Vector<MathObject> pageObjects;
    MathObject mObj;
    int oldSize;
    boolean problemsGenerated = false;
    for (int i = 0; i < getPages().size(); i++) {
        pageObjects = getPages().get(i).getObjects();
        oldSize = pageObjects.size();
        for (int j = 0; j < oldSize; j++) {
            mObj = pageObjects.get(j);
            if (mObj instanceof GeneratedProblem) {
                ((GeneratedProblem) mObj).generateNewProblem();
                problemsGenerated = true;
                j--;
                oldSize--;
            } else if (mObj instanceof Grouping && ((Grouping) mObj).containsGeneratedProblems()) {
                ((Grouping) mObj).generateNewVersion();
                problemsGenerated = true;
            }
        }
    }
    return problemsGenerated;
}
Also used : GeneratedProblem(doc.mathobjects.GeneratedProblem) Grouping(doc.mathobjects.Grouping) MathObject(doc.mathobjects.MathObject)

Example 7 with Grouping

use of doc.mathobjects.Grouping in project OpenNotebook by jaltekruse.

the class ObjectPropertiesFrame method buttonAction.

private void buttonAction(String s) {
    object.performAction(s);
    // when the document redraws itself
    if (!object.actionWasCancelled()) {
        notebookPanel.getCurrentDocViewer().addUndoState();
    }
    DocViewerPanel currentViewer = notebookPanel.getCurrentDocViewer();
    // at the time of this comment this is achieved with a double click
    if (currentViewer.getFocusedObject() != null && currentViewer.getFocusedObject().getParentContainer() instanceof Grouping) {
        ((Grouping) currentViewer.getFocusedObject().getParentContainer()).adjustSizeToFitChildren();
    }
    currentViewer.repaintDoc();
}
Also used : DocViewerPanel(doc_gui.DocViewerPanel) Grouping(doc.mathobjects.Grouping)

Example 8 with Grouping

use of doc.mathobjects.Grouping in project OpenNotebook by jaltekruse.

the class DocMouseListener method dragMouseToResizeObj.

private boolean dragMouseToResizeObj(MouseEvent e) {
    if (!(draggingDot || selectionRectBeingResized)) {
        // method is needed
        return false;
    }
    // one of the dots of an object is being moved to make it larger or
    // smaller
    // or the temporary selection rectangle is being resized
    PointInDocument docPt = docPanel.panelPt2DocPt(e.getX(), e.getY());
    MathObject objToResize = null;
    if (draggingDot) {
        // an object is focused and one of its resizing dots
        // has been contacted
        // resize the focues object
        objToResize = docPanel.getFocusedObject();
    } else if (selectionRectBeingResized) {
        // the user drew a selection
        // rectangle on the screen,
        // resize the selection
        // rectangle
        objToResize = docPanel.getSelectionRect();
    }
    Page pageOfResizeObject = objToResize.getParentPage();
    Page contactedPage = docPanel.getDoc().getPage(docPt.getPage());
    if (!docPt.isOutSidePage() && pageOfResizeObject == contactedPage) {
        if (selectionRectBeingResized) {
            // a special object that does note
            // exist in the document was
            // resized, it is used
            // to select multiple objects at
            // once and create groups
            MathObjectGUI.moveResizeDot(docPanel.getSelectionRect(), currentDragDot, docPt, this);
            adjustTempGroupSelection();
        } else {
            // a regular object was resized
            MathObjectGUI.moveResizeDot(objToResize, currentDragDot, docPt, this);
        }
        docPanel.repaintDoc();
        return true;
    } else {
        // the mouse moved outside of the page where the object to
        // resize resides
        Point pageOrigin = null;
        pageOrigin = docPanel.getPageOrigin(objToResize.getParentPage());
        // flags to indicate that a position has not been assigned to the
        // click
        int xMouseRequest = Integer.MAX_VALUE;
        int yMouseRequest = Integer.MAX_VALUE;
        if (e.getX() <= pageOrigin.getX()) {
            // event was to the left of the
            // document, send an resize
            // request with the edge of page
            // and the events given y
            // position
            xMouseRequest = 0;
        } else if (e.getX() >= pageOrigin.getX() + (int) (pageOfResizeObject.getWidth() * docPanel.getZoomLevel())) {
            xMouseRequest = pageOfResizeObject.getWidth();
        }
        if (e.getY() <= pageOrigin.getY()) {
            yMouseRequest = 0;
        } else if (e.getY() >= pageOrigin.getY() + (int) (pageOfResizeObject.getHeight() * docPanel.getZoomLevel())) {
            yMouseRequest = pageOfResizeObject.getHeight();
        }
        if (yMouseRequest == Integer.MAX_VALUE) {
            yMouseRequest = docPt.getyPos();
        }
        if (xMouseRequest == Integer.MAX_VALUE) {
            xMouseRequest = docPt.getxPos();
        }
        MathObjectGUI.moveResizeDot(objToResize, currentDragDot, new PointInDocument(1, xMouseRequest, yMouseRequest), this);
        if (objToResize.getParentContainer() instanceof Grouping) {
            ((Grouping) objToResize.getParentContainer()).adjustSizeToFitChildren();
        }
        if (selectionRectBeingResized) {
            // a special object that does note
            // exist in the document was
            // resized, it is used
            // to select multiple objects at
            // once and create groups
            adjustTempGroupSelection();
        }
        docPanel.repaintDoc();
    }
    return true;
}
Also used : Page(doc.Page) Grouping(doc.mathobjects.Grouping) Point(java.awt.Point) MathObject(doc.mathobjects.MathObject) Point(java.awt.Point) PointInDocument(doc.PointInDocument)

Example 9 with Grouping

use of doc.mathobjects.Grouping in project OpenNotebook by jaltekruse.

the class NotebookPanel method ungroup.

public void ungroup() {
    MathObject mObj = getCurrentDocViewer().getFocusedObject();
    if (mObj != null) {
        if (mObj instanceof Grouping) {
            if (mObj == getCurrentDocViewer().getTempGroup()) {
                getCurrentDocViewer().ungroupTempGroup();
            } else {
                ((Grouping) mObj).unGroup();
                mObj.getParentContainer().removeObject(mObj);
            }
            getCurrentDocViewer().setFocusedObject(null);
            getCurrentDocViewer().addUndoState();
            getCurrentDocViewer().repaint();
        }
    }
}
Also used : Grouping(doc.mathobjects.Grouping) MathObject(doc.mathobjects.MathObject)

Aggregations

Grouping (doc.mathobjects.Grouping)9 MathObject (doc.mathobjects.MathObject)6 Page (doc.Page)3 Point (java.awt.Point)3 PointInDocument (doc.PointInDocument)2 Rectangle (java.awt.Rectangle)2 Vector (java.util.Vector)2 Document (doc.Document)1 ProblemDatabase (doc.ProblemDatabase)1 AttributeException (doc.attributes.AttributeException)1 GeneratedProblem (doc.mathobjects.GeneratedProblem)1 ProblemNumberObject (doc.mathobjects.ProblemNumberObject)1 DocViewerPanel (doc_gui.DocViewerPanel)1