@Override public void gestureBegan(GesturePhaseEvent event) { magnification = 0; Point mouse = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(mouse, myFrame.getComponent()); Component deepest = SwingUtilities.getDeepestComponentAt(myFrame.getComponent(), mouse.x, mouse.y); ZoomableViewport viewport = (ZoomableViewport) SwingUtilities.getAncestorOfClass(ZoomableViewport.class, deepest); if (viewport != null) { Magnificator magnificator = viewport.getMagnificator(); if (magnificator != null) { Point at = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(at, (JComponent)viewport); viewport.magnificationStarted(at); myMagnifyingViewport = viewport; } } }
public EditorComponentImpl(@NotNull EditorImpl editor) { myEditor = editor; enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK); enableInputMethods(true); setFocusCycleRoot(true); setOpaque(true); putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, new Magnificator() { @Override public Point magnify(double scale, Point at) { VisualPosition magnificationPosition = myEditor.xyToVisualPosition(at); double currentSize = myEditor.getColorsScheme().getEditorFontSize(); int defaultFontSize = EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize(); myEditor.setFontSize(Math.max((int)(currentSize * scale), defaultFontSize)); return myEditor.visualPositionToXY(magnificationPosition); } }); myApplication = (ApplicationImpl)ApplicationManager.getApplication(); }
public ImageContainerPane(final ImageComponent imageComponent) { this.imageComponent = imageComponent; add(imageComponent); putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, new Magnificator() { @Override public Point magnify(double scale, Point at) { Point locationBefore = imageComponent.getLocation(); ImageZoomModel model = editor != null ? editor.getZoomModel() : getZoomModel(); double factor = model.getZoomFactor(); model.setZoomFactor(scale * factor); return new Point(((int)((at.x - Math.max(scale > 1.0 ? locationBefore.x : 0, 0)) * scale)), ((int)((at.y - Math.max(scale > 1.0 ? locationBefore.y : 0, 0)) * scale))); } }); }
public TrackpadZoomingTreeView(java.util.List<String> ruleNames, Tree tree, boolean highlightUnreachedNodes) { super(ruleNames, tree, highlightUnreachedNodes); //TODO: memory leak? putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, this); }