Package com.visitrend.ndvis.gui.spi

Examples of com.visitrend.ndvis.gui.spi.DataVisualization


        String path = preferences.get("img-path", "");
        JFileChooser chooser = new JFileChooser(path);
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        chooser.setAcceptAllFileFilterUsed(false);
        chooser.setFileFilter(DimStackImageFileFilter.getInstance());
        DataVisualization dataVis = owner.getActiveDataVisualization();
        int returnVal = chooser.showSaveDialog(dataVis.getTopComponent());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File img = chooser.getSelectedFile();

            // save path info for future file operations
            if (img.isDirectory()) {
                preferences.put("img-path", img.getAbsolutePath());
            } else {
                preferences.put("img-path", img.getParent());
            }

            // handle if file already exists
            if (img.exists()) {
                int answer = JOptionPane.showConfirmDialog(null,
                        "Overwrite existing file?");
                if (answer != JOptionPane.OK_OPTION) {
                    return;
                }
            } else {
                // If this is a new file, make sure
                // it has the necessary file ending
                if (FileUtils.getExtension(img) == null) {
                    javax.swing.filechooser.FileFilter filter = chooser.getFileFilter();
                    String str = img.getAbsolutePath()
                            + filter.getDescription();
                    img = new File(str);
                }
            }
            writeFile(img);
            dataVis.fireSaveStateChange(false);
        }
    }
View Full Code Here


        WindowManager.getDefault().getRegistry().addPropertyChangeListener(new PropertyChangeListener() {
            private DataVisualization lastActive = null;

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                DataVisualization active = getActiveDataVisualization();
                if(lastActive!=active){
                    lastActive=active;
                    fireActiveDataVisualizationChanged();
                }
            }
View Full Code Here

    public DataInfoINF getDataInfoForVisualization(DataVisualization datavis) {
        return datavis.getLookup().lookup(DataInfoINF.class);
    }

    public DataVisualization getActiveDataVisualization() {
        DataVisualization active = null;
        for(TopComponent tc: WindowManager.getDefault().getRegistry().getOpened()){
            if(tc instanceof DataVisualization){
                if(tc.isShowing()){
                    active=(DataVisualization) tc;
                }
View Full Code Here

        addNewImage();
    }

    public void addNewImage() {

        final DataVisualization imp = new ImagePanel();

        imp.getImagePane().setBorder(new EmptyBorder(0, 0, 0, 0));
        imp.addImagePanelListener(new DataVisualizationListener() {

            @Override
            public void originalVisualizationChanged(DataVisualizationChangedEvent event) {
                DataVisualization dataVis = (DataVisualization)event.getSource();
                dataVis.fireSaveStateChange(true);
                dataVis.getTopComponent().requestActive();
            }
        });
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

            @Override
View Full Code Here

    public void itemStateChanged(ItemEvent e) {
        change();
    }

    private void change() {
        DataVisualization active = NDVis.getDefault().getActiveDataVisualization();
        if (active!=null) {
            setEnabled(true);
            if (isSelected()) {
                ZoomHelper zh = zoomHelpers.get(active);
                if(zh == null){
View Full Code Here

        super("Fit to Window");
        this.view = NDVis.getDefault();
    }

    public void actionPerformed(ActionEvent arg0) {
        DataVisualization imgPanel = view.getActiveDataVisualization();
        if (imgPanel == null) {
            return;
        }

        // get the viewable area of the application where images are shown
        Rectangle viewableArea = view.getViewableDataVisualizationArea();
        if (viewableArea == null) {
            return;
        }

        // we're basing the resize on the viewableArea width
        if (viewableArea.width <= 0) {
            return;
        }

        BufferedImage img = imgPanel.getOffScreenImage();
        if (img == null) {
            return;
        }

        // calculate ratio by which img and ImagePanel should be scaled
        // so that their width is the same as the viewableArea
        double multipliar = (double) viewableArea.width
                / (double) img.getWidth();

        // if the multipliar is 1 then we won't do anything so just return
        if (multipliar == 1) {
            return;
        }

        // reset any priori image transformations
        imgPanel.resetImageManipulation();

        // set the new size of the ImagePanel
        imgPanel.getImagePane().setPreferredSize(new Dimension(viewableArea.width, (int) (img.getHeight() * multipliar)));
        imgPanel.getImagePane().revalidate();

        // finally, zoom the image to the new size using the multipliar
        imgPanel.getTransform().scale(multipliar, multipliar);
        imgPanel.getImagePane().repaint();
    }
View Full Code Here

        // Find data visualization that contains the event source
        Container parent = (Container) evt.getSource();
        while(!(parent instanceof DataVisualization)){
            parent = parent.getParent();
        }
        DataVisualization imgpan = (DataVisualization) parent;
        int imageHeight = imgpan.getOffScreenImage().getHeight() - 1;
        AffineTransform atx = imgpan.getTransform();
        Point2D p = evt.getPoint();
        try {
            // undo any transformations to get at where the point is in the
            // unaltered offscreen image
            p = atx.inverseTransform(p, p);
View Full Code Here

     * coordinates as parameter values in Parameters.
     *
     */
    public void originalVisualizationChanged(DataVisualizationChangedEvent event) {
        // System.out.println("in ParametersController.originalImageChanged()");
        DataVisualization imagePanel = (DataVisualization) event.getSource();

        /*
         * We remove this as an ImagePanelListener because we don't want to keep
         * adding ourselves back as a MouseMotionListener
         */
        imagePanel.removeImagePanelListener(this);
        /*
         * We add ourselves back as a MouseMotionListener to report mouse
         * coordinates on the panel.
         */
        imagePanel.getImagePane().addMouseMotionListener(this);
        /*
         * We'll say we're listening so future numParametersOnXchanged() and
         * parametersOrderChanged() method calls do in fact go through their
         * full procedure - see those for more info
         */
        imagePanel.setParamControllerListening(true);

        // parameter values will be reported shortly so we'll set this so that
        // other methods will actually pound the values if/when is necessary
        imagePanel.setPounded(false);
    }
View Full Code Here

     * here), which should (hopefuly) signify that everything has been updated
     * and is right again.
     */
    public void numParametersOnXchanged(ParametersChangedEvent event) {
        // System.out.println("numParametersOnXchanged");
        DataVisualization imagePanel = view;
        /*
         * It's possible that an image has not yet been created thus the
         * activeImagePanel would be null.
         */
        if (imagePanel == null) {
            // System.out.println("imagePanel was null");
            return;
        }

        /*
         * Just using a flag internal to ImagePanel so we don't repeat adding or
         * removing ourselves as listeners from this particular ImagePanel
         */
        if (!imagePanel.isParamControllerListening()) {
            return;
        } else {
            imagePanel.setParamControllerListening(false);
        }

        imagePanel.addImagePanelListener(this);
        imagePanel.getImagePane().removeMouseMotionListener(this);
        parameters.poundParamValues();
        imagePanel.setPounded(true);
    }
View Full Code Here

     * has been updated and is right again and we can then start listning to
     * mouse mostion events again.
     */
    public void parametersOrderChanged(ParametersChangedEvent pce) {
        // System.out.println("parametersOrderChanged");
        DataVisualization imagePanel = view;

        /*
         * It's possible that an image has not yet been created thus the
         * activeImagePanel would be null.
         */
        if (imagePanel == null) {
            System.out.println("imagePanel was null");
            return;
        }

        /*
         * Just using a flag internal to ImagePanel so we don't repeat adding or
         * removing ourselves as listeners from this particular ImagePanel
         */
        if (!imagePanel.isParamControllerListening()) {
            return;
        } else {
            imagePanel.setParamControllerListening(false);
        }

        imagePanel.addImagePanelListener(this);
        imagePanel.getImagePane().removeMouseMotionListener(this);
        parameters.poundParamValues();
        imagePanel.setPounded(true);
    }
View Full Code Here

TOP

Related Classes of com.visitrend.ndvis.gui.spi.DataVisualization

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.