示例#1
0
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   final int wheelRotation = e.getWheelRotation();
   final double newZoomFactor =
       layerCanvas.getViewport().getZoomFactor() * Math.pow(1.1, wheelRotation);
   layerCanvas.getViewport().setZoomFactor(newZoomFactor);
 }
示例#2
0
 public static void installLayerCanvasNavigation(LayerCanvas layerCanvas) {
   layerCanvas.setNavControlShown(true);
   final MouseHandler mouseHandler = new MouseHandler(layerCanvas);
   layerCanvas.addMouseListener(mouseHandler);
   layerCanvas.addMouseMotionListener(mouseHandler);
   layerCanvas.addMouseWheelListener(mouseHandler);
 }
 private void zoomToPixelResolution() {
   final ProductSceneView view = getCurrentView();
   if (view != null) {
     final LayerCanvas layerCanvas = view.getLayerCanvas();
     layerCanvas.getViewport().setZoomFactor(layerCanvas.getDefaultZoomFactor());
     maybeSynchronizeCompatibleProductViews();
   }
 }
示例#4
0
  public static void displayImages(
      String title,
      RenderedImage[] images,
      AffineTransform[] imageToModelTransforms,
      int levelCount) {
    final LayerCanvas layerCanvas = new LayerCanvas();
    installLayerCanvasNavigation(layerCanvas);
    final Layer collectionLayer = layerCanvas.getLayer();
    for (int i = 0; i < images.length; i++) {
      final ImageLayer layer = new ImageLayer(images[i], imageToModelTransforms[i], levelCount);
      collectionLayer.getChildren().add(layer);
    }

    openFrame(layerCanvas, title, new Rectangle(0, 0, 512, 512));
  }
示例#5
0
 public static void displayImage(
     File location, String extension, AffineTransform imageToModelTransform, int levelCount) {
   final LayerCanvas layerCanvas = new LayerCanvas();
   installLayerCanvasNavigation(layerCanvas);
   final Layer collectionLayer = layerCanvas.getLayer();
   final MultiLevelSource source =
       FileMultiLevelSource.create(location, extension, imageToModelTransform, levelCount);
   final ImageLayer layer = new ImageLayer(source);
   collectionLayer.getChildren().add(layer);
   final Rectangle viewportBounds = new Rectangle(0, 0, 640, 480);
   layerCanvas.setPreferredSize(new Dimension(640, 480));
   layerCanvas.getViewport().setViewBounds(viewportBounds);
   layerCanvas.getViewport().zoom(layer.getModelBounds());
   openFrame(layerCanvas, location.getPath(), viewportBounds);
 }
示例#6
0
 @Override
 public void mouseDragged(MouseEvent e) {
   final Point p = e.getPoint();
   final double dx = p.x - p0.x;
   final double dy = p.y - p0.y;
   layerCanvas.getViewport().moveViewDelta(dx, dy);
   p0 = p;
 }