use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method selectBoxFinish.
private boolean selectBoxFinish(final MouseEvent event) {
if (event.getButton() == this.selectBoxButton && this.selectBoxX1 != -1) {
if (clearOverlayAction(ACTION_SELECT_RECORDS)) {
final MapPanel map = getMap();
final GeometryFactory geometryFactory = map.getGeometryFactory();
BoundingBox boundingBox = geometryFactory.newBoundingBox(this.selectBoxX1, this.selectBoxY1, this.selectBoxX2, this.selectBoxY2);
final Viewport2D viewport = getViewport();
final double minSize = viewport.getModelUnitsPerViewUnit() * 10;
final double width = boundingBox.getWidth();
double deltaX = 0;
if (width < minSize) {
deltaX = (minSize - width) / 2;
}
final double height = boundingBox.getWidth();
double deltaY = 0;
if (height < minSize) {
deltaY = (minSize - height) / 2;
}
boundingBox = boundingBox.expand(deltaX, deltaY);
if (!boundingBox.isEmpty()) {
doSelectRecords(event, boundingBox);
}
selectBoxClear();
if (isMouseInMap()) {
setSelectCursor(event);
}
event.consume();
repaint();
return true;
}
}
return false;
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class SinglePage method print.
@Override
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) throws PrinterException {
if (pageIndex == 0) {
setGraphics((Graphics2D) graphics);
final int translateX = (int) pageFormat.getImageableX();
final int translateY = (int) pageFormat.getImageableY();
graphics.translate(translateX - 1, translateY - 1);
final Project project = getProject();
final MapPanel mapPanel = project.getMapPanel();
final Layer baseMapLayer = mapPanel.getBaseMapLayer();
render(baseMapLayer);
render(project);
return PAGE_EXISTS;
} else {
return NO_SUCH_PAGE;
}
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class MeasureOverlay method modeMeasureMove.
protected boolean modeMeasureMove(final MouseEvent event) {
if (isOverlayAction(MEASURE)) {
final MapPanel map = getMap();
final CloseLocation location = map.findCloseLocation(null, null, this.measureGeometry);
final List<CloseLocation> locations = new ArrayList<>();
if (location != null) {
locations.add(location);
}
final boolean hasMouseOver = setMouseOverLocations(locations);
// TODO make work with multi-part
if (!hasMouseOver) {
modeMeasureUpdateXorGeometry();
}
return true;
}
return false;
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class ZoomOverlay method panStart.
public boolean panStart(final MouseEvent event, final boolean drag) {
if (this.panX1 == -1) {
boolean pan = false;
final int button = event.getButton();
if (button == MouseEvent.BUTTON2) {
pan = true;
this.panButton = MouseEvent.BUTTON2;
} else if (!drag && button == MouseEvent.BUTTON1 && !hasOverlayAction()) {
if (event.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) {
pan = true;
this.panButton = MouseEvent.BUTTON1;
}
}
if (pan) {
if (setOverlayAction(ACTION_PAN)) {
final Viewport2D viewport = getViewport();
final int width = viewport.getViewWidthPixels();
final int height = viewport.getViewHeightPixels();
if (width > 0 && height > 0) {
final JComponent parent = (JComponent) getParent();
this.panImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
final Graphics2D graphics = (Graphics2D) this.panImage.getGraphics();
try {
final Insets insets = parent.getInsets();
graphics.translate(-insets.left, -insets.top);
graphics.setColor(Color.WHITE);
graphics.fillRect(insets.left, insets.top, width, height);
parent.paintComponents(graphics);
} finally {
graphics.dispose();
}
this.panX1 = this.panX2 = event.getX();
this.panY1 = this.panY2 = event.getY();
final MapPanel map = getMap();
map.setVisibleOverlay(this);
}
return true;
}
}
return false;
} else {
return true;
}
}
use of com.revolsys.swing.map.MapPanel in project com.revolsys.open by revolsys.
the class ZoomOverlay method mouseClicked.
@Override
public void mouseClicked(final MouseEvent event) {
if (canOverrideOverlayAction(ACTION_ZOOM)) {
final int button = event.getButton();
// Double click
if (event.getClickCount() == 2) {
final int x = event.getX();
final int y = event.getY();
int numSteps = 0;
if (button == MouseEvent.BUTTON1 && !hasOverlayAction() || button == MouseEvent.BUTTON2) {
// Left or middle button, zoom in
numSteps = -1;
} else if (button == MouseEvent.BUTTON3) {
// Right mouse button, zoom out
numSteps = 1;
}
if (numSteps != 0) {
final Viewport2D viewport = getViewport();
final Point mapPoint = viewport.toModelPoint(x, y);
final MapPanel map = getMap();
map.zoom(mapPoint, numSteps);
event.consume();
}
}
}
}
Aggregations