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