Search in sources :

Example 1 with MathObject

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

the class NotebookPanel method copy.

public void copy() {
    MathObject mObj = getCurrentDocViewer().getFocusedObject();
    if (mObj != null) {
        // application internal clipboard
        setClipBoardContents(mObj.clone());
        addToSystemClipboard(mObj);
    }
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 2 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 3 with MathObject

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

the class NotebookKeyboardListener method keyPressed.

@Override
public void keyPressed(KeyEvent e) {
    try {
        MathObject foc = notebook.getNotebookPanel().getCurrentDocViewer().getFocusedObject();
        if (foc == null) {
            // There is no focused object to accept the event
            return;
        }
        switch(e.getKeyCode()) {
            case KeyEvent.VK_DOWN:
                if (notebook.getNotebookPanel().getCurrentDocViewer().getPageGUI().getGUIForObj(foc).keyPressed(foc, PageGUI.DOWN)) {
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                    return;
                }
                if (foc != null) {
                    foc.setyPos(foc.getyPos() + 1);
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                }
                break;
            case KeyEvent.VK_UP:
                if (notebook.getNotebookPanel().getCurrentDocViewer().getPageGUI().getGUIForObj(foc).keyPressed(foc, PageGUI.UP)) {
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                    return;
                }
                if (foc != null) {
                    foc.setyPos(foc.getyPos() - 1);
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                }
                break;
            case KeyEvent.VK_LEFT:
                if (notebook.getNotebookPanel().getCurrentDocViewer().getPageGUI().getGUIForObj(foc).keyPressed(foc, PageGUI.LEFT)) {
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                    return;
                }
                if (foc != null) {
                    foc.setxPos(foc.getxPos() - 1);
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                }
                break;
            case KeyEvent.VK_RIGHT:
                if (notebook.getNotebookPanel().getCurrentDocViewer().getPageGUI().getGUIForObj(foc).keyPressed(foc, PageGUI.RIGHT)) {
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                    return;
                }
                if (foc != null) {
                    foc.setxPos(foc.getxPos() + 1);
                    notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                }
                break;
            default:
                notebook.getNotebookPanel().getCurrentDocViewer().getPageGUI().getGUIForObj(foc).keyPressed(foc, e.getKeyChar());
                notebook.getNotebookPanel().getCurrentDocViewer().repaintDoc();
                break;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : MathObject(doc.mathobjects.MathObject)

Example 4 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)

Example 5 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)

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