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);
}
}
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();
}
}
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();
}
}
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();
}
}
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;
}
}
Aggregations