Search in sources :

Example 11 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class KymographPanel method initStandAloneTimeSeries_private.

/**
 * Insert the method's description here.
 * Creation date: (12/14/2004 9:47:38 AM)
 * @param timeSeries double[][]
 * @param distances double[]
 */
private void initStandAloneTimeSeries_private(double[][] timeSeriesOrig, double[] accumDistancesOrig) throws DataAccessException {
    if (accumDistancesOrig.length != (timeSeriesOrig.length - 1)) {
        throw new IllegalArgumentException(this.getClass().getName() + " accumDistances.length != numSamplePoints");
    }
    timeSeriesDataOrig = timeSeriesOrig;
    accumDistancesDataOrig = accumDistancesOrig;
    currentTimes = timeSeriesDataOrig[0];
    // Resample for even distances
    RESAMP_SIZE = timeSeriesDataOrig.length - 1;
    int rvSize = (currentTimes.length) * RESAMP_SIZE;
    rawValues = new double[rvSize];
    double incr = accumDistancesDataOrig[accumDistancesDataOrig.length - 1] / (double) (RESAMP_SIZE - 1);
    currentDistances = new double[RESAMP_SIZE];
    for (int j = 0; j < currentTimes.length; j += 1) {
        int sourceIndex = 0;
        double currentDistance = 0;
        for (int k = 0; k < RESAMP_SIZE; k += 1) {
            while (currentDistance > accumDistancesDataOrig[sourceIndex + 1]) {
                sourceIndex += 1;
            }
            double subShort = currentDistance - accumDistancesDataOrig[sourceIndex];
            double subLong = accumDistancesDataOrig[sourceIndex + 1] - accumDistancesDataOrig[sourceIndex];
            double proportion = subShort / subLong;
            // System.out.println("prop="+proportion+" j="+j+" k="+k+" sourceIndex="+sourceIndex+"sourcedist="+accumDistancesDataOrig[sourceIndex]+" currentDistance="+currentDistance);
            double value = timeSeriesDataOrig[1 + sourceIndex + (proportion > .5 ? 1 : 0)][j];
            // double value = timeSeriesDataOrig[1+sourceIndex][j] + ((timeSeriesDataOrig[1+sourceIndex+1][j]-timeSeriesDataOrig[1+sourceIndex][j])*proportion);
            // if(k == (RESAMP_SIZE-1)){
            // value = timeSeriesDataOrig[timeSeriesDataOrig.length-1][j];
            // }
            rawValues[(j * RESAMP_SIZE) + (k)] = value;
            currentDistances[k] = currentDistance;
            currentDistance += incr;
            if (currentDistance > accumDistancesDataOrig[accumDistancesDataOrig.length - 1]) {
                currentDistance = accumDistancesDataOrig[accumDistancesDataOrig.length - 1];
            }
        }
    }
    Range minmaxRange = null;
    allDataMMMH = calcMMM(rawValues);
    if (allDataMMMH != null) {
        minmaxRange = allDataMMMH.getRange();
    }
    SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, rawValues, minmaxRange, 0, RESAMP_SIZE, 1, 0, accumDistancesDataOrig[accumDistancesDataOrig.length - 1], currentTimes.length, RESAMP_SIZE, currentTimes[0], currentTimes[currentTimes.length - 1] - currentTimes[0]);
    getImagePaneScroller1().getImagePaneModel().setSourceData(sdi);
    getImagePlaneManager1().setSourceDataInfo(sdi);
    if (isInit) {
        zoomUpJButton_ActionPerformed(null);
        zoomDownJButton_ActionPerformed(null);
    // getImagePaneScroller1().getImagePaneModel().changeZoomToFillViewport();
    }
    getDisplayJLabel().setText(NONE_MESSAGE);
    configurePlotData(currentSelectionImg.x, currentSelectionImg.y);
}
Also used : Range(org.vcell.util.Range) SourceDataInfo(cbit.image.SourceDataInfo) Point(java.awt.Point)

Example 12 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class ImagePaneScroller method viewport1_Change.

/**
 * Comment
 */
private void viewport1_Change() {
    // 
    // -----Begin Fix for Jumping scroll bars
    // This CRRRAAAPPP!!!!!! is here because of an apparent bug in ScrollPaneLayout that
    // does not take into account the scrollbar sizes when calculating the size of the viewport
    java.awt.Rectangle availR = new java.awt.Rectangle(getJScrollPane1().getSize());
    java.awt.Insets insets = getJScrollPane1().getInsets();
    availR.x = insets.left;
    availR.y = insets.top;
    availR.width -= insets.left + insets.right;
    availR.height -= insets.top + insets.bottom;
    /* If there's a visible column header remove the space it 
	 * needs from the top of availR.  The column header is treated 
	 * as if it were fixed height, arbitrary width.
	 */
    java.awt.Rectangle colHeadR = new java.awt.Rectangle(0, availR.y, 0, 0);
    javax.swing.JViewport colHead = getJScrollPane1().getColumnHeader();
    if ((colHead != null) && (colHead.isVisible())) {
        int colHeadHeight = colHead.getPreferredSize().height;
        colHeadR.height = colHeadHeight;
        availR.y += colHeadHeight;
        availR.height -= colHeadHeight;
    }
    /* If there's a visible row header remove the space it needs
	 * from the left of availR.  The row header is treated 
	 * as if it were fixed width, arbitrary height.
	 */
    java.awt.Rectangle rowHeadR = new java.awt.Rectangle(availR.x, 0, 0, 0);
    javax.swing.JViewport rowHead = getJScrollPane1().getRowHeader();
    boolean leftToRight = true;
    if ((rowHead != null) && (rowHead.isVisible())) {
        int rowHeadWidth = rowHead.getPreferredSize().width;
        rowHeadR.width = rowHeadWidth;
        availR.width -= rowHeadWidth;
        if (leftToRight) {
            // ibm.597
            // ibm.597
            rowHeadR.x = availR.x;
            // ibm.597
            availR.x += rowHeadWidth;
        } else {
            // ibm.597
            // ibm.597
            rowHeadR.x = availR.x + availR.width;
        }
    // ibm.597
    }
    // System.out.println("availR="+availR);
    // System.out.println("viewportBounds="+getJScrollPane1().getViewport().getBounds());
    // System.out.println("hsb="+getJScrollPane1().getHorizontalScrollBar().getSize()+" "+getJScrollPane1().getHorizontalScrollBar().getInsets());
    // System.out.println("vsb="+getJScrollPane1().getVerticalScrollBar().getSize()+" "+getJScrollPane1().getVerticalScrollBar().getInsets());
    // System.out.println();
    getJScrollPane1().getViewport().reshape(availR.x, availR.y, (int) availR.getWidth() - (int) getJScrollPane1().getVerticalScrollBar().getSize().getWidth(), (int) availR.getHeight() - (int) getJScrollPane1().getHorizontalScrollBar().getSize().getHeight());
    // 
    if (getviewport1() != null && getJScrollPane1().getViewport() != null) {
        // System.out.println("ImagePaneScroller.viewport bounds=           "+getviewport1().getBounds());
        // System.out.println("ImagePaneScroller.viewport borderbounds *** ="+getJScrollPane1().getViewportBorderBounds());
        // System.out.println("ImagePaneScroller.viewport size=             "+getJScrollPane1().getViewport().getSize());
        // System.out.println("ImagePaneScroller.viewport viewpostion=      "+getJScrollPane1().getViewport().getViewPosition());
        // System.out.println("ImagePaneScroller.viewport viewsize=         "+getJScrollPane1().getViewport().getViewSize());
        // if(getviewport1().getBounds().equals(getJScrollPane1().getViewportBorderBounds())){
        java.awt.Point viewULC = getJScrollPane1().getViewport().getViewPosition();
        java.awt.Rectangle visibleArea = getJScrollPane1().getViewportBorderBounds();
        visibleArea.setLocation(getJScrollPane1().getViewport().getViewPosition());
        getImagePaneView().getImagePaneModel().setViewport(visibleArea);
        // 
        if (!hasUserSetZoom && getImagePaneModel() != null && getImagePaneModel().getSourceData() != null) {
            SourceDataInfo sdi = getImagePaneModel().getSourceData();
            int boundsXSize = (int) getJScrollPane1().getViewportBorderBounds().getWidth();
            int boundsYSize = (int) getJScrollPane1().getViewportBorderBounds().getHeight();
            int zoom = Math.min(boundsXSize / (sdi.getXSize() * 2), boundsYSize / (sdi.getYSize() * 2));
            zoom = (zoom < 1 ? 1 : zoom);
            getImagePaneModel().setZoom(zoom);
        }
        // 
        if (getImagePaneModel().getSourceData() != null) {
            // java.awt.Point vpPos = getJScrollPane1().getViewport().getViewPosition();
            // java.awt.Dimension vpDim = getJScrollPane1().getViewport().getSize();
            // java.awt.geom.Point2D.Double unitOrigin =
            // getImagePaneModel().calculateImagePointUnitized(
            // new java.awt.Point((int)vpPos.getX(),(int)vpPos.getY()));
            // java.awt.geom.Point2D.Double unitend =
            // getImagePaneModel().calculateImagePointUnitized(
            // new java.awt.Point((int)(vpPos.getX()+vpDim.getWidth()),(int)(vpPos.getY()+vpDim.getHeight())));
            // double worldExtent = getImagePaneModel().getSourceData().getExtent().getX()*(unitend.getX()-unitOrigin.getX());
            // double worldOrigin =
            // getImagePaneModel().getSourceData().getOrigin().getX()+
            // getImagePaneModel().getSourceData().getExtent().getX()*unitOrigin.getX();
            // ((ImagePaneRuler)getJScrollPane1().getColumnHeader().getView()).setWorldOrigin(worldOrigin);
            // ((ImagePaneRuler)getJScrollPane1().getColumnHeader().getView()).setWorldExtent(worldExtent);
            // 
            // 
            // 
            // double worldExtent = getImagePaneModel().getSourceData().getExtent().getX();
            // double worldOrigin = getImagePaneModel().getSourceData().getOrigin().getX();
            // ((ImagePaneRuler)getJScrollPane1().getColumnHeader().getView()).setWorldOrigin(worldOrigin);
            // ((ImagePaneRuler)getJScrollPane1().getColumnHeader().getView()).setWorldExtent(worldExtent);
            sizeHeaders();
        }
        getJScrollPane1().getColumnHeader().getView().repaint();
        getJScrollPane1().getRowHeader().getView().repaint();
    // getJScrollPane1().getColumnHeader().getView().invalidate();
    // revalidate();
    // }
    // System.out.println();
    }
}
Also used : SourceDataInfo(cbit.image.SourceDataInfo)

Example 13 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class ImagePaneScrollerTest method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    // Insert code to start the application here.
    // Create default image
    int w = Integer.valueOf(args[2]).intValue();
    int h = Integer.valueOf(args[3]).intValue();
    String type = args[0];
    SourceDataInfo sdi = getExampleSDI(type, w, h);
    DisplayAdapterService das = null;
    if (type.equals("double")) {
        das = new DisplayAdapterService();
        das.setActiveScaleRange(new Range(0, 450));
        das.setValueDomain(new Range(-50, 550));
        das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createGraySpecialColors(), DisplayAdapterService.GRAY);
        das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), DisplayAdapterService.BLUERED);
        das.setActiveColorModelID(DisplayAdapterService.GRAY);
    } else if (type.equals("index")) {
        das = new DisplayAdapterService();
        das.addColorModelForIndexes(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.GRAY);
        das.addColorModelForIndexes(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.BLUERED);
        das.setActiveColorModelID(DisplayAdapterService.GRAY);
    }
    try {
        javax.swing.JFrame frame = new javax.swing.JFrame();
        ImagePaneScroller aImagePaneScroller;
        aImagePaneScroller = new ImagePaneScroller();
        aImagePaneScroller.getImagePaneModel().setSourceData(sdi);
        aImagePaneScroller.getImagePaneModel().setDisplayAdapterService(das);
        // aImagePaneScroller.getImagePaneModel().setBackgroundColor(java.awt.Color.yellow);
        if (args[1].equals("true")) {
            aImagePaneScroller.getImagePaneModel().setMode(ImagePaneModel.MESH_MODE);
        }
        javax.swing.JPanel jp = new javax.swing.JPanel();
        jp.setLayout(new java.awt.BorderLayout());
        jp.add(aImagePaneScroller);
        frame.setContentPane(jp);
        frame.setSize(aImagePaneScroller.getSize());
        frame.addWindowListener(new java.awt.event.WindowAdapter() {

            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            }
        });
        frame.show();
        java.awt.Insets insets = frame.getInsets();
        frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
        frame.setVisible(true);
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JPanel");
        exception.printStackTrace(System.out);
    }
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) SourceDataInfo(cbit.image.SourceDataInfo) Range(org.vcell.util.Range)

Example 14 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class ImagePaneScrollerTest method getExampleSDI.

/**
 * Insert the method's description here.
 * Creation date: (10/12/00 2:08:24 PM)
 * @return cbit.image.SourceDataInfo
 */
public static final SourceDataInfo getExampleSDI(String type, int w, int h) {
    int numZ = 20;
    SourceDataInfo sdi = null;
    if (type.equals("rgb")) {
        int[] pixels = new int[w * h * numZ];
        for (int z = 0; z < numZ; z += 1) {
            for (int y = 0; y < h; y += 1) {
                for (int x = 0; x < w; x += 1) {
                    if (y % 2 == 0) {
                        if (x % 2 == 0) {
                            pixels[x + (y * w) + (z * w * h)] = 0x00ff0000;
                        }
                    } else {
                        if (x % 2 != 0) {
                            pixels[x + (y * w) + (z * w * h)] = 0x00ff0000;
                        }
                    }
                    if (x >= w / 3 && x < w / 2 && y >= h / 3 && y < h / 1.5) {
                        pixels[x + (y * w) + (z * w * h)] = 0xFF * z / numZ * 0xFFFF;
                    }
                }
            }
        }
        // 
        sdi = new SourceDataInfo(SourceDataInfo.INT_RGB_TYPE, pixels, new org.vcell.util.Extent(1, 2, 3), new org.vcell.util.Origin(0, -5, 10), null, 0, w, 1, h, w, numZ, h * w);
    } else if (type.equals("double")) {
        double[] pixels = new double[w * h * numZ];
        for (int z = 0; z < numZ; z += 1) {
            for (int y = 0; y < h; y += 1) {
                for (int x = 0; x < w; x += 1) {
                    pixels[x + (y * w) + (z * w * h)] = -150 + ((double) x / ((double) w - 1)) * (800);
                    if (y > h - (h / 4)) {
                        pixels[x + (y * w) + (z * w * h)] = Double.POSITIVE_INFINITY;
                    }
                    if (x >= w / 3 && x < w / 2 && y >= h / 3 && y < h / 1.5) {
                        pixels[x + (y * w) + (z * w * h)] = 300 * z / numZ;
                    }
                }
            }
        }
        sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, pixels, new org.vcell.util.Extent(1, 2, 3), new org.vcell.util.Origin(0, -5, 10), new Range(-150, 650), 0, w, 1, h, w, numZ, h * w);
    } else if (type.equals("index")) {
        byte[] pixels = new byte[w * h * numZ];
        for (int i = 0; i < pixels.length; i += 1) {
            pixels[i] = (byte) (i % 256);
        }
        sdi = new SourceDataInfo(SourceDataInfo.INDEX_TYPE, pixels, new org.vcell.util.Extent(1, 2, 3), new org.vcell.util.Origin(0, -5, 10), null, 0, w, 1, h, w, numZ, h * w);
    } else if (type.equals("facecube")) {
        numZ = 50;
        w = 50;
        h = 50;
        int[] pixels = new int[w * h * numZ];
        int[] facePixels = new int[w * h];
        java.awt.image.BufferedImage face = new java.awt.image.BufferedImage(w, h, java.awt.image.BufferedImage.TYPE_INT_RGB);
        java.awt.Graphics2D g2d = face.createGraphics();
        g2d.setRenderingHint(java.awt.RenderingHints.KEY_FRACTIONALMETRICS, java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g2d.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setFont(new java.awt.Font("SansSerif", java.awt.Font.PLAIN, 6));
        // g2d.scale(2,2);
        // java.awt.Font smallFont = g2d.getFont().deriveFont(10);
        // g2d.setFont(smallFont);
        int xStart = 0;
        int xEnd = 0;
        int xIncr = 0;
        int yStart = 0;
        int yEnd = 0;
        int yIncr = 0;
        int zStart = 0;
        int zEnd = 0;
        int zIncr = 0;
        for (int i = 0; i < 2; i += 1) {
            g2d.setColor(java.awt.Color.red);
            g2d.fillRect(0, 0, w, h);
            g2d.setColor(java.awt.Color.white);
            switch(i) {
                case 0:
                    xStart = 0;
                    xEnd = w;
                    xIncr = 1;
                    yStart = 0;
                    yEnd = w * h;
                    yIncr = w;
                    zStart = 0;
                    zEnd = w * h * numZ;
                    zIncr = w * h;
                    g2d.drawString("- FRNT(-) +", 0, 15);
                    g2d.drawString("- FRNT (+) +", 0, h - 2);
                    break;
                case 1:
                    xStart = 0;
                    xEnd = w;
                    xIncr = 1;
                    yStart = 0;
                    yEnd = w * h;
                    yIncr = w;
                    zStart = 0;
                    zEnd = w * h * numZ;
                    zIncr = w * h;
                    g2d.drawString("- BTM(-) +", 0, 15);
                    g2d.drawString("- BTM (+) +", 0, h - 2);
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    break;
                default:
            }
            face.getRGB(0, 0, w, h, facePixels, 0, w);
            for (int z = zStart; z != zEnd; z += zIncr * (zEnd - zStart < 0 ? -1 : 1)) {
                int index = 0;
                for (int y = yStart; y != yEnd; y += yIncr * (yEnd - yStart < 0 ? -1 : 1)) {
                    for (int x = xStart; x != xEnd; x += xIncr * (xEnd - xStart < 0 ? -1 : 1)) {
                        pixels[x + (y) + (z)] = facePixels[index];
                        index += 1;
                    }
                }
            }
        }
        sdi = new SourceDataInfo(SourceDataInfo.INT_RGB_TYPE, pixels, new org.vcell.util.Extent(1, 2, 3), new org.vcell.util.Origin(0, -5, 10), null, 0, w, 1, h, w, numZ, h * w);
    }
    // 
    return sdi;
}
Also used : SourceDataInfo(cbit.image.SourceDataInfo) Range(org.vcell.util.Range)

Example 15 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class ImagePlaneManagerPanel method setSourceDataInfo.

/**
 * Sets the sourceDataInfo property (cbit.image.SourceDataInfo) value.
 * @param sourceDataInfo The new value for the property.
 * @see #getSourceDataInfo
 */
public void setSourceDataInfo(SourceDataInfo sourceDataInfo) {
    SourceDataInfo oldValue = fieldSourceDataInfo;
    fieldSourceDataInfo = sourceDataInfo;
    firePropertyChange("sourceDataInfo", oldValue, sourceDataInfo);
    // 
    // Sometimes if a change of data timepoint,variable,paramscan takes a long time and the user moves the mouse
    // into the data display before the new data has fully updated the wrong value will be displayed
    // make sure the data value text display is always updated if the mouse is in the data display
    updateInfo(lastValidMouseEvent);
    if (lastValidMouseEvent != null) {
        // make sure the tooltip is updated if the mouse is in the data display
        ToolTipManager.sharedInstance().mouseMoved(lastValidMouseEvent);
    }
    // 
    getImagePaneScroller1().repaint();
}
Also used : SourceDataInfo(cbit.image.SourceDataInfo)

Aggregations

SourceDataInfo (cbit.image.SourceDataInfo)18 Range (org.vcell.util.Range)5 DisplayAdapterService (cbit.image.DisplayAdapterService)3 ImageException (cbit.image.ImageException)3 VCImage (cbit.image.VCImage)3 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)2 VariableType (cbit.vcell.math.VariableType)2 DataOperationResults (cbit.vcell.simdata.DataOperationResults)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 ArrayList (java.util.ArrayList)2 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)2 ImagePaneModel (cbit.image.ImagePaneModel)1 ImagePlaneManager (cbit.image.ImagePlaneManager)1 VCImageUncompressed (cbit.image.VCImageUncompressed)1 ImagePlaneManagerPanel (cbit.image.gui.ImagePlaneManagerPanel)1 Plot2D (cbit.plot.Plot2D)1 PlotData (cbit.plot.PlotData)1 PlotPane (cbit.plot.gui.PlotPane)1 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1