@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { visibleRect = g.getClipBounds(visibleRect); if (visibleRect==null) { // ??? visibleRect = ((JComponent)c).getVisibleRect(); } g.setColor(color); if (left==1) { g.drawLine(0,visibleRect.y, 0,visibleRect.y+visibleRect.height); } else { g.drawLine(width-1,visibleRect.y, width-1,visibleRect.y+visibleRect.height); } }
Rectangle r = ((JComponent) mapPane).getVisibleRect(); if (!(r == null || r.isEmpty())) { int dx = 0;
Rectangle visibleRect = component.getVisibleRect(); visibleRect.y = component.getHeight() - visibleRect.height; component.scrollRectToVisible(visibleRect);
/** * Zoom in by the currently set increment, with the map centred at the location (in world * coords) of the mouse click * * @param e map mapPane mouse event */ @Override public void onMouseClicked(MapMouseEvent e) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = e.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale * zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }
/** * Zoom out by the currently set increment, with the map centred at the location (in world * coords) of the mouse click * * @param ev the mouse event */ @Override public void onMouseClicked(MapMouseEvent ev) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = ev.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale / zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }
@Override public void onMouseWheelMoved(MapMouseEvent ev) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect();
protected boolean isInTarget(Point point) { Rectangle bounds = component.getVisibleRect(); return bounds.contains(point); }
protected boolean isVisible(JComponent c, int x, int y) { Rectangle visible = c.getVisibleRect(); return visible.contains(x, y); }
public void computeSource() { Rectangle vr = c.getVisibleRect(); source = new Rectangle(dest); if(source.x < vr.x) source.x = vr.x; else if(source.x > vr.x+vr.width) source.x = vr.x+vr.width-source.width; if(source.y < vr.y) source.y = vr.y; else if(source.y > vr.y+vr.height) source.y = vr.y+vr.height-source.height; }
/** * Calls {@link #repaintNapkinParent(JComponent,Rectangle)} with the visible * region of the given JComponent as the extra parameter. * * @param component The bottom component to repaint. */ private void repaintNapkinParent(JComponent component) { repaintNapkinParent(component, component.getVisibleRect()); }
public static void scrollToBottom(JComponent component) { Rectangle visibleRect = component.getVisibleRect(); visibleRect.y = component.getHeight() - visibleRect.height; component.scrollRectToVisible(visibleRect); }
private void scroll(int aDeltaX, int aDeltaY) { JComponent component = (JComponent) theScrollPane.getViewport().getView(); Rectangle rect = component.getVisibleRect(); rect.x += aDeltaX; rect.y += aDeltaY; component.scrollRectToVisible(rect); // thePopupMenu.setVisible(false); }
/** * Find the rectangular area that is visible in screen coordinates * for the given component. */ protected Rectangle getRectOnScreen (JComponent comp) { Rectangle r = comp.getVisibleRect(); Point p = comp.getLocationOnScreen(); r.translate(p.x, p.y); return r; }
void scroll(final int aDeltaX, final int aDeltaY, final boolean _end) { if (theComponent == null) { return; } final Rectangle rect = theComponent.getVisibleRect(); rect.x += aDeltaX; rect.y += aDeltaY; theComponent.scrollRectToVisible(rect); if (_end) { thePopupMenu.setVisible(false); } }
/** Clears the current view. **/ synchronized public void clearView() { Rectangle r = getVisibleRect(); getGraphics().clearRect(r.x, r.y, r.width, r.height); }
private void scroll(int aDeltaX, int aDeltaY) { JComponent component = (JComponent) _scrollPane.getViewport().getView(); Rectangle rect = component.getVisibleRect(); rect.x += xOffset + aDeltaX; rect.y += yOffset + aDeltaY; component.scrollRectToVisible(rect); _popupMenu.setVisible(false); } }
public synchronized void scrollTo(Rectangle dest) { this.dest = dest; computeSource(); computeVector(); if(c.getVisibleRect().intersects(dest)) { c.scrollRectToVisible(dest); completed(); } else { startTimer(); } }
public boolean isOverlayVisibleInParentComponent() { Rectangle vr = SwingUtilities.convertRectangle(parentComponent, parentComponent.getVisibleRect(), parentFrame.getJavaContainer()); Rectangle cr = SwingUtilities.convertRectangle(parentFrame.getLayeredPane(), content.getBounds(), parentFrame.getJavaContainer()); return vr.intersects(cr); }
private boolean pan (Widget widget, Point newLocation) { if (scrollPane == null || scene != widget.getScene ()) return false; newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation)); SwingUtilities.convertPointToScreen (newLocation, scene.getView ()); JComponent view = scene.getView (); Rectangle rectangle = view.getVisibleRect (); rectangle.x += lastLocation.x - newLocation.x; rectangle.y += lastLocation.y - newLocation.y; view.scrollRectToVisible (rectangle); lastLocation = newLocation; return true; }
private boolean pan (Widget widget, Point newLocation) { if (scrollPane == null || scene != widget.getScene ()) return false; newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation)); SwingUtilities.convertPointToScreen (newLocation, scene.getView ()); JComponent view = scene.getView (); Rectangle rectangle = view.getVisibleRect (); rectangle.x += lastLocation.x - newLocation.x; rectangle.y += lastLocation.y - newLocation.y; view.scrollRectToVisible (rectangle); lastLocation = newLocation; return true; }