/*========================================================================= Program: FusionViewer Module: $RCSfile: FusionDisplayModel.java,v $ Language: Java Date: $Date: 2007/02/02 19:27:10 $ Version: $Revision: 1.3 $ Copyright (c) Insightful Corporation. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ package org.fusionviewer.model; import java.io.IOException; /**\class FusionDisplayModel * \brief Contains display settings for a set of images with a linked cursor * position and parameters for fused(overlaid) image display. */ public class FusionDisplayModel extends LinkedCursorDisplayModel { /** * Used by model listeners to signal the alpha blending has changed. */ public final static int FUSIONMODE_CHANGED = ImageDisplayModel.LAST_MESSAGE_VALUE + 1; //6 public final static int ALPHA_CHANGED = FUSIONMODE_CHANGED + 1; //7 public final static int CHECKERBOARD_CHANGED = ALPHA_CHANGED + 1; //8 public final static int SPLITWINDOW_CHANGED = CHECKERBOARD_CHANGED + 1; //9 /** * Rendering modes */ public final static int ALPHABLEND_MODE = 1; public final static int CHECKERBOARD_MODE = 2; public final static int SPLITWINDOW_MODE = 3; private float m_alpha = 0.5f; private int m_checkerboardSize = 50; private int m_fusionMode = ALPHABLEND_MODE; //default private float m_splitWindowTickSpacing = 20.0f; private float m_splitWindowAlpha = 1.0f; /** * Create a display model with a number of linked images. * * @param numImages number of images * @throws IOException */ public FusionDisplayModel(int numImages, boolean fusionLayout, int refId){ super(numImages, fusionLayout, refId); } /** * Set the alpha used in alpha blend fusion mode. * * @param alpha alpha value (0.0-1.0) */ public void setAlpha(float alpha) { if (m_alpha == alpha) return; if ((alpha < 0.0f) || (alpha > 1.0f)) throw new IllegalArgumentException("Alpha value is out of range: " + alpha); m_alpha = alpha; notifyListeners(ALPHA_CHANGED, ImageDisplayModel.ALL_IMAGES); } /** * Get the alpha value * * @return alpha */ public float getAlpha() { return m_alpha; } /** * Set the size of each checkerboard grid for the checkerboard fusion mode. * * @param size size of each grid block */ public void setCheckerboardSize(int size) { if (m_checkerboardSize == size) return; if (size <= 0) throw new IllegalArgumentException("Checkerboard size is out of range: " + size); m_checkerboardSize = size; notifyListeners(CHECKERBOARD_CHANGED, ImageDisplayModel.ALL_IMAGES); } /** * Get the checkerboard grid size * * @return size of each grid block */ public int getCheckerboardSize() { return m_checkerboardSize; } /** * Set the mode used to blend images. * * @param mode image blending mode */ public void setFusionMode(int mode) { if (m_fusionMode == mode) return; if ((mode < ALPHABLEND_MODE) || (mode > SPLITWINDOW_MODE)) throw new IllegalArgumentException("Unrecognized fusion mode: " + mode); m_fusionMode = mode; notifyListeners(FUSIONMODE_CHANGED, ImageDisplayModel.ALL_IMAGES); } /** * Get the image blending mode * * @return image fusion mode */ public int getFusionMode() { return m_fusionMode; } /** * Set the spacing between tickmarks in split window mode * * @param spacing tickmark spacing in millimeters */ public void setSplitWindowTickSpacing(float spacing) { if (m_splitWindowTickSpacing == spacing) return; if (spacing <= 0.0f) throw new IllegalArgumentException("Tickmark spacing out of range: " + spacing); m_splitWindowTickSpacing = spacing; notifyListeners(SPLITWINDOW_CHANGED, ImageDisplayModel.ALL_IMAGES); } /** * Get the spacing between tickmarks in split window mode * * @return tickmark spacing in millimeters */ public float getSplitWindowTickSpacing() { return m_splitWindowTickSpacing; } /** * Set the alpha blending value for the split window * * @param alpha split window alpha value (0.0 - 1.0) */ public void setSplitWindowAlpha(float alpha) { if (m_splitWindowAlpha == alpha) return; if ((alpha < 0.0f) || (alpha > 1.0f)) throw new IllegalArgumentException("Alpha value is out of range: " + alpha); m_splitWindowAlpha = alpha; notifyListeners(SPLITWINDOW_CHANGED, ImageDisplayModel.ALL_IMAGES); } /** * Get the split window alpha value * * @return split window alpha value */ public float getSplitWindowAlpha() { return m_splitWindowAlpha; } }