use of doc.Page 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;
}
Aggregations