Search in sources :

Example 1 with ImagePaneModel

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

the class FormatSpecificSpecs method getImageDimension.

public static Dimension getImageDimension(int meshMode, int imageScale, CartesianMesh mesh, int normalAxis) {
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    Dimension dim = FormatSpecificSpecs.getMeshDimensionUnscaled(normalAxis, mesh);
    dim.width = imagePaneModel.getScaledLength(dim.width);
    dim.height = imagePaneModel.getScaledLength(dim.height);
    return dim;
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Dimension(java.awt.Dimension)

Example 2 with ImagePaneModel

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

the class PDEOffscreenRenderer method getScaledRGBVolume.

private BufferedImage getScaledRGBVolume(CartesianMesh mesh, int meshMode, int imageScale, boolean bBackground) {
    Dimension dim = FormatSpecificSpecs.getMeshDimensionUnscaled(getNormalAxis(), getServerPDEDataContext().getCartesianMesh());
    int width = (int) dim.getWidth();
    int height = (int) dim.getHeight();
    double[] volumeData = new double[width * height];
    if (!bBackground) {
        // if(bNeedsDefaultScaling){setDefaultScaling();}
        double notInDomainValue = getDisplayAdapterService().getValueDomain().getMin() - 1.0;
        double[] values = getServerPDEDataContext().getDataValues();
        int[] dataIndices = getServerPDEDataContext().getCartesianMesh().getVolumeSliceIndices(getNormalAxis(), getSlice());
        for (int i = 0; i < dataIndices.length; i++) {
            double value = values[dataIndices[i]];
            if (domainValid != null) {
                if (domainValid.get(dataIndices[i]) || domainValid.isEmpty()) {
                    volumeData[i] = value;
                } else {
                    volumeData[i] = notInDomainValue;
                }
            } else {
                volumeData[i] = value;
            }
        }
    }
    SourceDataInfo sourceDataInfo = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, volumeData, mesh.getExtent(), mesh.getOrigin(), new Range(0, 1), 0, width, 1, height, width, 1, 0);
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setSourceData(sourceDataInfo);
    imagePaneModel.setBackgroundColor(Color.black);
    imagePaneModel.setDisplayAdapterService(getDisplayAdapterService());
    // getDisplayAdapterService().setActiveScaleRange(new Range(0,1));
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    imagePaneModel.setViewport(new Rectangle(imagePaneModel.getScaledLength(width), imagePaneModel.getScaledLength(height)));
    imagePaneModel.updateViewPortImage();
    if (bBackground) {
        int[] internalBuffer = ((DataBufferInt) (imagePaneModel.getViewPortImage().getRaster().getDataBuffer())).getData();
        Arrays.fill(internalBuffer, getDisplayAdapterService().getSpecialColors()[DisplayAdapterService.NULL_COLOR_OFFSET]);
    }
    BufferedImage bufferedImage = imagePaneModel.getViewPortImage();
    imagePaneModel.setDisplayAdapterService(null);
    return bufferedImage;
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) DataBufferInt(java.awt.image.DataBufferInt) SourceDataInfo(cbit.image.SourceDataInfo) Range(org.vcell.util.Range) BufferedImage(java.awt.image.BufferedImage)

Example 3 with ImagePaneModel

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

the class PDEOffscreenRenderer method getPixelDelta.

private Coordinate getPixelDelta(Extent extent, CartesianMesh mesh, int meshMode, int imageScale) {
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    double pixelScaleX = extent.getX() / imagePaneModel.getScaledLength(mesh.getSizeX());
    double pixelScaleY = extent.getY() / imagePaneModel.getScaledLength(mesh.getSizeY());
    double pixelScaleZ = extent.getZ() / imagePaneModel.getScaledLength(mesh.getSizeZ());
    return new Coordinate(pixelScaleX, pixelScaleY, pixelScaleZ);
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Coordinate(org.vcell.util.Coordinate)

Aggregations

ImagePaneModel (cbit.image.ImagePaneModel)3 Dimension (java.awt.Dimension)2 SourceDataInfo (cbit.image.SourceDataInfo)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 DataBufferInt (java.awt.image.DataBufferInt)1 Coordinate (org.vcell.util.Coordinate)1 Range (org.vcell.util.Range)1