Search in sources :

Example 11 with MathObject

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

the class NotebookPanel method delete.

public void delete() {
    if (getCurrentDocViewer().getFocusedObject() != null) {
        MathObject mObj = getCurrentDocViewer().getFocusedObject();
        mObj.getParentContainer().removeObject(mObj);
        if (mObj == getCurrentDocViewer().getTempGroup()) {
            getCurrentDocViewer().resetAndRemoveTempGroup();
        }
        mObj.setParentContainer(null);
        mObj.setJustDeleted(true);
        getCurrentDocViewer().setFocusedObject(null);
        getCurrentDocViewer().addUndoState();
        getCurrentDocViewer().repaint();
    } else if (getCurrentDocViewer().getSelectedPage() != null) {
        deletePage();
    } else {
        JOptionPane.showMessageDialog(null, "Please select a page or object first.", ERROR, JOptionPane.INFORMATION_MESSAGE);
        return;
    }
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 12 with MathObject

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

the class NotebookPanel method group.

public void group() {
    MathObject focusedObj = getCurrentDocViewer().getFocusedObject();
    if (focusedObj != null && focusedObj == getCurrentDocViewer().getTempGroup()) {
        getCurrentDocViewer().getTempGroup().getParentContainer().removeObject(focusedObj);
        MathObject newGroup = getCurrentDocViewer().getTempGroup().clone();
        focusedObj.getParentContainer().addObject(newGroup);
        getCurrentDocViewer().resetTempGroup();
        // make sure this comes after the call to resetAndRemoveTempGroup, when a
        // new focused object is set it places the objects in the temp group
        // back on the page, which is not what is needed here
        getCurrentDocViewer().setFocusedObject(newGroup);
        getCurrentDocViewer().addUndoState();
        getCurrentDocViewer().repaint();
    }
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 13 with MathObject

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

the class NotebookPanel method paste.

public void paste() {
    MathObject focusedObj = getCurrentDocViewer().getFocusedObject();
    if (getClipBoardContents() == null) {
        JOptionPane.showMessageDialog(null, "Clipboard is empty.", "Empty Clipboard", JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (focusedObj != null) {
        MathObject newObj = getClipBoardContents().clone();
        newObj.setxPos(focusedObj.getxPos());
        // offset the new object a little so the user knows that it was added
        newObj.setyPos(focusedObj.getyPos() + 10);
        newObj.setParentContainer(focusedObj.getParentContainer());
        focusedObj.getParentContainer().addObject(newObj);
        getCurrentDocViewer().setFocusedObject(newObj);
    } else if (getCurrentDocViewer().getSelectedPage() != null) {
        MathObject newObj = getClipBoardContents().clone();
        newObj.setParentContainer(getCurrentDocViewer().getSelectedPage());
        getCurrentDocViewer().getSelectedPage().addObject(newObj);
        getCurrentDocViewer().setFocusedObject(newObj);
    } else {
        JOptionPane.showMessageDialog(null, "Please select a page, or an object on the desired page first.", "Select Location for Paste", JOptionPane.WARNING_MESSAGE);
        return;
    }
    getCurrentDocViewer().addUndoState();
    getCurrentDocViewer().repaint();
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 14 with MathObject

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

the class NotebookPanel method destroyDoc.

public void destroyDoc(Document doc) {
    for (Page p : doc.getPages()) {
        p.setParentDoc(null);
        for (MathObject mObj : p.getObjects()) {
            mObj.setParentContainer(null);
        }
        p.removeAllObjects();
    }
    doc.removeAllPages();
    doc.setDocViewerPanel(null);
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 15 with MathObject

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

the class NotebookPanel method bringToBack.

public void bringToBack() {
    MathObject mObj = getCurrentDocViewer().getFocusedObject();
    if (mObj != null) {
        mObj.getParentPage().bringObjectToBack(mObj);
        getCurrentDocViewer().addUndoState();
        getCurrentDocViewer().repaint();
    }
}
Also used : MathObject(doc.mathobjects.MathObject)

Aggregations

MathObject (doc.mathobjects.MathObject)31 Grouping (doc.mathobjects.Grouping)6 PointInDocument (doc.PointInDocument)4 Point (java.awt.Point)4 AttributeException (doc.attributes.AttributeException)3 Page (doc.Page)2 GeneratedProblem (doc.mathobjects.GeneratedProblem)2 ProblemGenerator (doc.mathobjects.ProblemGenerator)2 ProblemNumberObject (doc.mathobjects.ProblemNumberObject)2 TextObject (doc.mathobjects.TextObject)2 Rectangle (java.awt.Rectangle)2 MathObjectAttribute (doc.attributes.MathObjectAttribute)1 RectangleObject (doc.mathobjects.RectangleObject)1 VariableValueInsertionProblem (doc.mathobjects.VariableValueInsertionProblem)1 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Graphics2D (java.awt.Graphics2D)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1