diff --git a/CSJ2K/CSJ2K/AssemblyInfo.cs b/CSJ2K/AssemblyInfo.cs
similarity index 100%
rename from CSJ2K/CSJ2K/AssemblyInfo.cs
rename to CSJ2K/AssemblyInfo.cs
diff --git a/CSJ2K/CSJ2K.sln b/CSJ2K/CSJ2K.sln
deleted file mode 100644
index 02ebd5e8..00000000
--- a/CSJ2K/CSJ2K.sln
+++ /dev/null
@@ -1,84 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSJ2K", "CSJ2K\CSJ2K.csproj", "{1EA0F9BA-0194-4F08-9E55-89888D5A4724}"
-EndProject
-Project("{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}") = "j2kdecoder", "jj2kdecoder\j2kdecoder.vjsproj", "{32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}"
-EndProject
-Project("{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}") = "j2kencoder", "jj2kencoder\j2kencoder.vjsproj", "{F6477386-69EA-494B-AEC0-5E3A1FDBA10D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "codectest", "codectest\codectest.csproj", "{08EBCC10-76CD-4198-9F60-E8091432E4D8}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Debug|x86.ActiveCfg = Debug|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Release|Any CPU.Build.0 = Release|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {1EA0F9BA-0194-4F08-9E55-89888D5A4724}.Release|x86.ActiveCfg = Release|Any CPU
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Debug|Any CPU.ActiveCfg = Debug|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Debug|x86.ActiveCfg = Debug|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Debug|x86.Build.0 = Debug|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Release|Any CPU.ActiveCfg = Release|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Release|Mixed Platforms.ActiveCfg = Release|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Release|Mixed Platforms.Build.0 = Release|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Release|x86.ActiveCfg = Release|x86
- {32801F5D-4A99-47E2-B1A3-62A8F3ABFA99}.Release|x86.Build.0 = Release|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Debug|Any CPU.ActiveCfg = Debug|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Debug|x86.ActiveCfg = Debug|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Debug|x86.Build.0 = Debug|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Release|Any CPU.ActiveCfg = Release|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Release|Mixed Platforms.ActiveCfg = Release|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Release|Mixed Platforms.Build.0 = Release|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Release|x86.ActiveCfg = Release|x86
- {F6477386-69EA-494B-AEC0-5E3A1FDBA10D}.Release|x86.Build.0 = Release|x86
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Debug|x86.ActiveCfg = Debug|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Release|Any CPU.Build.0 = Release|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {08EBCC10-76CD-4198-9F60-E8091432E4D8}.Release|x86.ActiveCfg = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(TeamFoundationVersionControl) = preSolution
- SccNumberOfProjects = 5
- SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
- SccTeamFoundationServer = https://tfs03.codeplex.com/
- SccLocalPath0 = .
- SccProjectUniqueName1 = CSJ2K\\CSJ2K.csproj
- SccProjectName1 = CSJ2K
- SccLocalPath1 = CSJ2K
- SccProjectUniqueName2 = jj2kdecoder\\j2kdecoder.vjsproj
- SccProjectName2 = jj2kdecoder
- SccLocalPath2 = jj2kdecoder
- SccProjectUniqueName3 = jj2kencoder\\j2kencoder.vjsproj
- SccProjectName3 = jj2kencoder
- SccLocalPath3 = jj2kencoder
- SccProjectUniqueName4 = codectest\\codectest.csproj
- SccProjectName4 = codectest
- SccLocalPath4 = codectest
- EndGlobalSection
-EndGlobal
diff --git a/CSJ2K/CSJ2K/CSJ2K.csproj b/CSJ2K/CSJ2K/CSJ2K.csproj
deleted file mode 100644
index c5eef00c..00000000
--- a/CSJ2K/CSJ2K/CSJ2K.csproj
+++ /dev/null
@@ -1,388 +0,0 @@
- Since the methods in this class require the presence of a shared library
- /// with the name defined in SHLIB_NAME it is necessary to load it prior to
- /// making use of any such methods. All methods that require the shared library
- /// will automatically load the library if that has not been already done. The
- /// library might also be manually loaded with the 'loadLibrary()' method of
- /// this class.
- ///
- /// This class provides only static methods. It should not be instantiated.
- ///
- /// Currently the only native services available is settings relative to
- /// POSIX threads, which are not accessible from the Java API.
- ///
- /// Currently the methods in this class make sense with POSIX threads only,
- /// since they access POSIX threads settings. POSIX threads are most used under
- /// UNIX and UNIX-like operating systems and are mostly referred to as "native"
- /// threads in Java Virtual Machine (JVM) implementations.
- ///
- /// The shared library SHLIB_NAME uses functions of the POSIX thread library
- /// (i.e. 'pthread'). Calling the methods that use the 'pthread' library will
- /// most prbably cause the Java Virtual Machine (JVM) to crash if it is not
- /// using the POSIX threads, due to unsatisfied references. For instance, JVMs
- /// that use "green" threads will most certainly crash. POSIX threads are
- /// referred to as "native" threads in JVMs under UNIX operating systems.
- ///
- /// On Operating Systems where POSIX threads are not available (typically
- /// Windows 95/98/NT/2000, MacIntosh, OS/2) there is no problem since the
- /// SHLIB_NAME, if available, will not make use of POSIX threads library
- /// functions, thus no problem should occur.
- ///
- /// For JVM implementations that use POSIX threads with
- /// PTHREAD_SCOPE_SYSTEM scheduling scope or JVM implementations that use
- /// Windows(R) threads and maybe others, setting the concurrency level has
- /// no effect. In this cases the number of CPUs that can be exploited by
- /// the JVM is not limited in principle, all CPUs are available to the JVM.
- ///
- /// For JVM implementations that use "green" threads setting the
- /// concurrency level, and thus calling this method, makes no sense, since
- /// "green" threads are all contained in one user process and can not use
- /// multiple CPUs. In fact calling this method can result in a JVM crash is
- /// the shared library SHLIB_NAME has been compiled to use POSIX threads.
- ///
- ///
First the decoder should be initialized with a ParameterList object - * given through the constructor. The when the run() method is invoked and the - * decoder executes. The exit code of the class can be obtained with the - * getExitCode() method, after the constructor and after the run method. A - * non-zero value indicates that an error has ocurred.
- * - *The decoding chain corresponds to the following sequence of modules:
- * - *The 2 last modules cannot be used at the same time and corresponds - * respectively to the writing of decoded image into a file or the graphical - * display of this same image.
- * - *The behaviour of each module may be modified according to the current - * tile-component. All the specifications are kept in modules extending - * ModuleSpec and accessible through an instance of DecoderSpecs class.
- * - * @see BitstreamReaderAgent - * @see EntropyDecoder - * @see ROIDeScaler - * @see Dequantizer - * @see InverseWT - * @see ImgDataConverter - * @see InvCompTransf - * @see ImgWriter - * @see BlkImgDataSrcImageProducer - * @see ModuleSpec - * @see DecoderSpecs - * */ -public class Decoder implements Runnable -{ - - /** Parses the inputstream to analyze the box structure of the JP2 - * file. */ - private ColorSpace csMap = null; - - /** Reference to the TitleUpdater instance. Only used when decoded image - * is displayed */ - TitleUpdater title = null; - - /** False if the Decoder instance is self-contained process, false if - * thrown by another process (i.e by a GUI)*/ - private boolean isChildProcess = false; - - /** The exit code of the run method */ - private int exitCode; - - /** The parameter list (arguments) */ - private ParameterList pl; - - /** Information contained in the codestream's headers */ - private HeaderInfo hi; - - /** The default parameter list (arguments) */ - private ParameterList defpl; - - /** The valid list of options prefixes */ - private final static char vprfxs[] = {BitstreamReaderAgent.OPT_PREFIX, - EntropyDecoder.OPT_PREFIX, - ROIDeScaler.OPT_PREFIX, - Dequantizer.OPT_PREFIX, - InvCompTransf.OPT_PREFIX, - HeaderDecoder.OPT_PREFIX, - ColorSpaceMapper.OPT_PREFIX - }; - - /** Frame used to display decoded image */ - private Frame win = null; - - /** The component where the image is to be displayed */ - private ImgScrollPane isp; - - /** The parameter information for this class */ - private final static String[][] pinfo = { - { "u", "[on|off]", - "Prints usage information. "+ - "If specified all other arguments (except 'v') are ignored","off"}, - { "v", "[on|off]", - "Prints version and copyright information","off"}, - { "verbose", "[on|off]", - "Prints information about the decoded codestream","on"}, - { "pfile", "An example use could be: The image data is not rescaled to fit the available dynamic range (not
- * even the alpha values for RGBA data). BlkImgDataSrc sources with 1, 3 and 4 components are supported. If 1, it
- * is assumed to be gray-level data. If 3 it is assumed to be RGB data, in
- * that order. If 4 it is assumed to be RGBA data (RGB plus alpha plane), in
- * that order. All components must have the same size. This method uses the JVM default Toolkit, which might not be what it
- * is desired. This method uses the component's toolkit. The toolkit of a component
- * may change if it is moved from one frame to another one, since it is
- * the frame that controls which toolkit is used. Delivery is performed in "parallel" to all the registered image
- * consumers. By "parallel" it is meant that each line of the image is
- * delivered to all consumers before delivering the next line. If the data returned by the BlkImgDataSrc source happens to be
- * progressive (see BlkImgDataSrc and DataBlk) then the abort condition is
- * sent to the image consumers and no further data is delivered. Once all the data is sent to a consumer this one is automatically
- * removed from the list of registered ones, unless an abort happens. To start the BlkImgDataSrc is set to tile (0,0), and the tiles are
- * produced in raster sacn order. Once the last tile is produced,
- * setTile(0,0) is called again, which signals that we are done with the
- * current tile, which might free up resources. Currently this call is ignored (which is perfectly legal according
- * to the ImageProducer interface specification). The following key sequences are defined:
- * The amount by which the arrows scroll the image is determined by the
- * modifier keys. If the Ctrl key is held down, the block increment will be
- * used, otherwise the unit increment will. If the Shift key is held down then
- * the increment is multiplied by ACCEL_FACTOR. That is the Ctrl key selects
- * between unit and block increments, while the Shift key selects between
- * normal and accelerated mode.
- *
- * */
-public class ImgKeyListener extends KeyAdapter {
-
- /** Frame used to display tools */
- Frame helpFrame = null;
-
- /** The component where the image is displayed */
- ImgScrollPane isp;
-
- /** Decoder instance */
- Decoder dec;
-
- /** The acceleration factor when the shift key is pressed: 10 */
- public static final int ACCEL_FACTOR = 10;
-
- /**
- * Instantiate a new ImgKeyListener that will work on the specified
- * ImgScrollPane.
- *
- * @param isp The image scroll pane on which the actions should
- * operate.
- *
- * @param dec The decoder instance
- * */
- public ImgKeyListener(ImgScrollPane isp,Decoder dec) {
- this.isp = isp;
- this.dec = dec;
- }
-
- /**
- * Hanldes the keyPressed events. Normal keys are not treated here because
- * some don't have a defined keycode (as incredible as it might seem!).
- *
- * @param evt The key event to process.
- * */
- public void keyPressed(KeyEvent evt) {
- Adjustable adj;
-
- // Do nothing if consumed
- if (evt.isConsumed()) return;
-
- // Perform action based on key
- switch (evt.getKeyCode()) {
- case KeyEvent.VK_LEFT: // Move left
- adj = isp.getHAdjustable();
- adj.setValue(adj.getValue()-calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_RIGHT: // Move right
- adj = isp.getHAdjustable();
- adj.setValue(adj.getValue()+calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_UP: // Move up
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()-calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_DOWN: // Move down
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()+calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_PAGE_UP: // Move up by a page
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()-adj.getBlockIncrement());
- break;
- case KeyEvent.VK_PAGE_DOWN: // Move down by a page
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()+adj.getBlockIncrement());
- break;
- case KeyEvent.VK_C:
- // Exit if ctrl is pressed
- if (evt.isControlDown()) {
- dec.exit();
- }
- break;
- default:
- return;
- }
-
- // Consume the event so nothing else is done
- evt.consume();
- }
-
- /**
- * Handles the key typed event. Normal (i.e. "text") keys are handled
- * here.
- *
- * @param evt The key event to process.
- * */
- public void keyTyped(KeyEvent evt) {
-
- // Do nothing if consumed
- if (evt.isConsumed()) return;
-
- // Perform action based on key
- switch (evt.getKeyChar()) {
- case '+':
- case '=':
- // Zoom in
- isp.zoom(2f);
- break;
- case '-':
- // Zoom out
- isp.zoom(0.5f);
- break;
- case '1':
- // Set zoom to 1
- isp.setZoom(1f);
- break;
- case 'q':
- case 'Q':
- // Exit
- dec.exit();
- break;
- case 'h':
- case 'H':
- // Help display
- if(helpFrame==null){
- helpFrame = new Frame("Tools");
- helpFrame.add(getHelp());
- helpFrame.pack();
- helpFrame.setResizable(false);
- helpFrame.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- helpFrame.setVisible(false);
- }
- });
- }
- if(helpFrame.isVisible())
- helpFrame.setVisible(false);
- else
- helpFrame.setVisible(true);
- break;
- default:
- return;
- }
-
- // Consume the event so nothing else is done
- evt.consume();
- }
-
- /**
- * Returns the increment based on the modifier keys of the KeyEvent. If
- * control is down then the Adjustable block increment is used, otherwise
- * the unit one is used. If the shift key is down the increment is
- * multiplied by ACCEL_FACTOR.
- *
- * @param evt The KeyEvent fom where to obtain the modifiers
- *
- * @param adj The Adjustable from where to obtain the increments
- * */
- private int calcIncrement(KeyEvent evt, Adjustable adj) {
- int incr;
- // Control selects block instead of unit
- if (evt.isControlDown()) {
- incr = adj.getBlockIncrement();
- }
- else {
- incr = adj.getUnitIncrement();
- }
- // Shift accelerates by ACCEL_FACTOR
- if (evt.isShiftDown()) {
- incr *= ACCEL_FACTOR;
- }
- return incr;
- }
-
- /**
- * Create a help TextArea concerning the tools associated with keys.
- *
- * @return The help TextArea
- *
- */
- private static TextArea getHelp(){
- TextArea ta = new TextArea("",17,61,TextArea.SCROLLBARS_NONE);
- ta.setEditable(false);
- ta.setFont(new Font("Monospaced",Font.PLAIN,10));
-
- ta.append("The following key sequences are recognized in the \n"+
- "image display window:\n\n");
- ta.append("'-' : zoom out by a factor of 2.\n");
- ta.append("'+' or '=' : zoom in by a factor of 2.\n");
- ta.append("'1' : set the zoom factor to 1 (i.e. no zoom).\n");
- ta.append(" Objects of this class must be registerd as both mouse listener and mouse
- * motion listener.
- *
- * While the dragging is taking place the cursor is changed to the
- * MOVE_CURSOR type. The original cursor is restored when the mouse is
- * released after the drag.
- *
- * */
-public class ImgMouseListener extends MouseAdapter
- implements MouseMotionListener {
- /** The component where the image is displayed */
- ImgScrollPane isp;
-
- /** The horizontal coordinate where the drag starts */
- int startMouseX;
-
- /** The vertical coordinate where the drag starts */
- int startMouseY;
-
- /** The horizontal scroll position when the drag started */
- int startScrollX;
-
- /** The vertical scroll position when the drag started */
- int startScrollY;
-
- Cursor prevCursor;
-
- /**
- * Instantiate a new ImgMouseListener that will work on the specified
- * ImgScrollPane.
- *
- * @param isp The image scroll pane on which the actions should operate.
- * */
- public ImgMouseListener(ImgScrollPane isp) {
- this.isp = isp;
- }
-
- public void mousePressed(MouseEvent e) {
- // Get the possibly start drag position
- startMouseX = e.getX();
- startMouseY = e.getY();
- // Get the start scroll position
- startScrollX = isp.getHAdjustable().getValue();
- startScrollY = isp.getVAdjustable().getValue();
- }
-
- public void mouseReleased(MouseEvent e) {
- // Restore the last cursor, if any
- if (prevCursor != null) {
- isp.setCursor(prevCursor);
- prevCursor = null;
- }
- }
-
- public void mouseDragged(MouseEvent evt) {
- int scrollX,scrollY;
-
- // Set the drag cursor
- if (prevCursor == null) {
- prevCursor = isp.getCursor();
- isp.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
- }
-
- // Calculate new scroll position and set it
- scrollX = startScrollX + startMouseX - evt.getX();
- scrollY = startScrollY + startMouseY - evt.getY();
- isp.setScrollPosition(scrollX,scrollY);
- }
-
- public void mouseMoved(MouseEvent evt) {
- }
-}
diff --git a/CSJ2K/jj2kdecoder/disp/ImgScrollPane.jsl b/CSJ2K/jj2kdecoder/disp/ImgScrollPane.jsl
deleted file mode 100644
index 7c4dcb44..00000000
--- a/CSJ2K/jj2kdecoder/disp/ImgScrollPane.jsl
+++ /dev/null
@@ -1,1402 +0,0 @@
-/*
- * CVS identifier:
- *
- * $Id: ImgScrollPane.java,v 1.10 2000/12/04 17:19:27 grosbois Exp $
- *
- * Class: ImgScrollPane
- *
- * Description: The zoom factor by default is 1. It can be changed with the 'zoom()' and
- * 'setZoom()' methods. The maximum zoom factor is defined by MAX_ZOOM.
- *
- * The zoom scaling is done directly by the AWT display system. In general
- * it is performed by dropping or repeating lines. It is just intended to
- * provide a display zoom and not for proper scaling of an image.
- *
- * The scrolling can be performed by copying the actual displayed data to
- * the new scrolled position and redrawing the damaged parts, or by redrawing
- * the entire displayed image portion at the new scrolled position. Which is
- * more efficient depends on the JVM and working environment. By default it is
- * done by copying since it tends to provide less annoying visual artifacts
- * while scrolling, but that can be changed with 'setCopyScroll()'.
- *
- * This class is very similar to the AWT ScrollPane one, but it is
- * optimized for display of large images and does not suffer from the problems
- * of ScrollPane when changing zoom. The Adjustable elements that represent
- * the scrollbars are made available as in ScrollPane, but the minimum,
- * maximum, visible amount and block increment should not be set
- * (IllegalArgumentException is thrown if attempted), since they are set
- * internally by this class.
- *
- * Focus and key event listeners that are registered are in fact registered
- * with the components that implement the three areas (the image display and
- * the two scrollbars) so that if any such event is fired in any of these
- * areas it is handled by the registered listener.
- *
- * Mouse and mouse movement event listeners that are registered are in fact
- * registered with the image display component only. The mouse and mouse
- * movement events on the scrollbars are handled by the Scrollbar default
- * listeners only.
- *
- * Although it is implemented as a container, it behaves like a
- * component. Specifically no components can be added or removed from objects
- * of this class. Furthermore, no layout manager can be set. It is internally
- * set and it can not be changed.
- *
- * The implementation uses a lightweight container with an inner class to
- * display the image itself, and two scrollbars. The layout manager is a
- * BorderLayout.
- *
- * This class should be really implemented as a Component, but it is
- * implemented as a Container for easyness. It should not be assumed it is a
- * subclass of Container since in the future it might be rewritten as a
- * subclass of Component only.
- *
- *
- * @see ScrollPane
- *
- * @see Adjustable
- * */
-public class ImgScrollPane extends Container {
-
- /** The ID for always visible scrollbars */
- public final static int SCROLLBARS_ALWAYS = ScrollPane.SCROLLBARS_ALWAYS;
-
- /** The ID for as needed visible scrollbars */
- public final static int SCROLLBARS_AS_NEEDED =
- ScrollPane.SCROLLBARS_AS_NEEDED;
-
- /** The ID for never visible scrollbars */
- public final static int SCROLLBARS_NEVER = ScrollPane.SCROLLBARS_NEVER;
-
- /** The maximum possible zoom factor: 32. */
- // This is used because factors too large cause problems with JVMs.
- public static final float MAX_ZOOM = 32f;
-
- /** The thickness of the scrollbars: 16 pixels */
- final static int SCROLLBAR_THICKNESS = 16;
-
- /** The inetrnal gap between the elements, in pixels: 0 */
- final static int INTERNAL_GAP = 0;
-
- /** The propertion between the visible scrollbar length and the block
- * increment amount: 0.8 */
- final static float BLOCK_INCREMENT_PROPORTION = 0.8f;
-
- /** The horizontal scrollbar.
- *
- * @serial
- */
- ISPScrollbar hsbar;
-
- /** The vertical scrollabr.
- *
- * @serial
- */
- ISPScrollbar vsbar;
-
- /** The image display
- *
- * @serial
- */
- private ImageScrollDisplay imgDisplay;
-
- /** The scrollbar type (always, as needed, etc.)
- *
- * @serial
- */
- private int sbType;
-
- /** The zoom to use in displaying the image. A factor larger than one
- * produces a zoom in effect.
- *
- * @serial
- */
- private float zoom = 1f;
-
- /** The zoom used in the last scrollbar calculation.
- *
- * @serial
- */
- private float lastZoom;
-
- /** The viewable size used in the last scrollbar calculation.
- *
- * @serial
- */
- private Dimension lastSize;
-
- /** If scrolling is to be done by copying ot not. If not done by copying
- * everything is redrawn.
- *
- * @serial*/
- private boolean copyScroll = true;
-
- /**
- * Creates a new ImgScrollPane with SCROLLBARS_AS_NEEDED scrollbars.
- * */
- public ImgScrollPane() {
- this(SCROLLBARS_AS_NEEDED);
- }
-
- /**
- * Creates a new ImgScrollPane with the specified type of scrollbar
- * visibility.
- *
- * @param svt The scrollbar visibility type
- * */
- public ImgScrollPane(int svt) {
- // Initialize
- super.setLayout(new BorderLayout(INTERNAL_GAP,INTERNAL_GAP));
- sbType = svt;
- hsbar = new ISPScrollbar(Scrollbar.HORIZONTAL,0,1,0,1);
- vsbar = new ISPScrollbar(Scrollbar.VERTICAL,0,1,0,1);
- imgDisplay = new ImageScrollDisplay();
- super.add(hsbar,BorderLayout.SOUTH);
- super.add(vsbar,BorderLayout.EAST);
- super.add(imgDisplay,BorderLayout.CENTER);
-
- // Set the initial scrollbar visibility
- switch (svt) {
- case SCROLLBARS_NEVER:
- case SCROLLBARS_AS_NEEDED:
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- break;
- case SCROLLBARS_ALWAYS:
- hsbar.setVisible(true);
- vsbar.setVisible(true);
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Sets the image to display in this component. If the image is not
- * ready for display it will be prepared in the current thread. The
- * current zoom factor applies.
- *
- * If the image is not ready for display (i.e. it has not been
- * rendered at its natural size) it will be rendered in the current
- * thread, if not being already rendered in another one. This means
- * that the current thread can block until the image is ready.
- *
- * If the image is rendered incrementally (it depends on the
- * underlying 'ImageProducer') it will be displayed in that way if the
- * incremental display is set for the Component class. See the
- * 'imageUpdate()' method of the 'Component' class.
- *
- * If the image is the same as the current one nothing is done.
- *
- * @param img The image to display.
- *
- * @see Component#imageUpdate
- * */
- public void setImage(Image img) {
- imgDisplay.setImage(img);
- }
-
- /**
- * Returns the image that is displayed in this component.
- *
- * @return The image displayed in this component, or null if none.
- * */
- public synchronized Image getImage() {
- return imgDisplay.img;
- }
-
- /**
- * Sets the zoom factor to display the image. A zoom factor larger than 1
- * corresponds to a zoom in. A factor of 1 corresponds to no
- * scaling. After setting the zoom factor the component is invalidated and
- * 'repaint()' is automatically called so that the image is redrawn at the
- * new zoom factor. In order to revalidate the layout 'validate()' should
- * be called on one of the parent containers. If the new zoom factor is
- * larger than MAX_ZOOM, then MAX_ZOOM will be used.
- *
- * @param zf The zoom factor
- * */
- public synchronized void setZoom(float zf) {
- if (zf == zoom || (zf > MAX_ZOOM && zoom == MAX_ZOOM)) {
- // No change => do nothing
- return;
- }
- // Set the zoom factor and recalculate the component dimensions
- zoom = zf;
- if (zoom > MAX_ZOOM) zoom = MAX_ZOOM;
- setScrollbars();
- // Check if we need to change the scrollbar display
- if (sbType == SCROLLBARS_AS_NEEDED) doLayout();
- // We need to erase previous scaled image
- imgDisplay.erase = true;
- // Redraw image
- imgDisplay.repaint();
- }
-
- /**
- * Modifies the current zoom factor by the given multiplier. After setting
- * the zoom factor the component is invalidated and 'repaint()' is
- * automatically called so that the image is redrawn at the new zoom
- * factor. In order to revalidate the layout 'validate()' should be called
- * on one of the parent containers. If the resulting zoom factor is larger
- * than MAX_ZOOM, then MAX_ZOOM will be used.
- *
- * @param zm The zoom multiplier to apply.
- * */
- public synchronized void zoom(float zm) {
- setZoom(zoom*zm);
- }
-
- /**
- * Returns the current zoom factor.
- *
- * @return The current zoom factor
- * */
- public synchronized float getZoom() {
- return zoom;
- }
-
- /**
- * Returns the Adjustable object which represents the state of the
- * horizontal scrollbar.
- * */
- public Adjustable getHAdjustable() {
- return hsbar;
- }
-
- /**
- * Returns the Adjustable object which represents the state of the
- * vertical scrollbar.
- * */
- public Adjustable getVAdjustable() {
- return vsbar;
- }
-
- /**
- * Returns the display policy for the scrollbars.
- *
- * @return the display policy for the scrollbars
- * */
- public int getScrollbarDisplayPolicy() {
- return sbType;
- }
-
- /**
- * Sets the display policy for the scrollbars.
- *
- * @param v the display policy for the scrollbars
- * */
- public void setScrollbarDisplayPolicy(int v) {
- // If no change do nothing
- if (v == sbType) return;
- switch (sbType) {
- case SCROLLBARS_NEVER:
- case SCROLLBARS_AS_NEEDED:
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- break;
- case SCROLLBARS_ALWAYS:
- hsbar.setVisible(true);
- vsbar.setVisible(true);
- break;
- default:
- throw new IllegalArgumentException();
- }
- // Now redo the layout
- doLayout();
- }
-
- /**
- * Scrolls to the specified position within the image. Specifying a
- * position outside of the legal scrolling bounds of the image will scroll
- * to the closest legal position. This is a convenience method which
- * interfaces with the Adjustable objects which represent the state of the
- * scrollbars.
- *
- * @param x the x position to scroll to
- *
- * @param y the y position to scroll to
- * */
- public synchronized void setScrollPosition(int x, int y) {
- hsbar.setValueI(x);
- vsbar.setValueI(y);
- // Check if we need to repaint
- x = hsbar.getValue(); // get the actual value for check
- y = vsbar.getValue(); // get the actual value for check
- if (imgDisplay.lastUpdateOffset != null &&
- imgDisplay.lastUpdateOffset.x == x &&
- imgDisplay.lastUpdateOffset.y == y) {
- return; // No change
- }
- // New value changes from last drawn => repaint
- imgDisplay.repaint();
- }
-
- /**
- * Scrolls to the specified position within the image. Specifying a
- * position outside of the legal scrolling bounds of the image will scroll
- * to the closest legal position. This is a convenience method which
- * interfaces with the Adjustable objects which represent the state of the
- * scrollbars.
- *
- * @param p the position to scroll to
- * */
- public synchronized void setScrollPosition(Point p) {
- setScrollPosition(p.x,p.y);
- }
-
- /**
- * Returns the current x,y position within the child which is displayed at
- * the 0,0 location of the scrolled panel's view port. This is a
- * convenience method which interfaces with the adjustable objects which
- * represent the state of the scrollbars.
- *
- * @return the coordinate position for the current scroll position
- * */
- public Point getScrollPosition() {
- return new Point(hsbar.getValue(),vsbar.getValue());
- }
-
- /**
- * Returns the current size of the image scroll pane's view port. This is
- * the size of the image display area. If this component has not been
- * layed out yet the value is not defined.
- *
- * @return The size of the image display area
- * */
- public Dimension getViewportSize() {
- return imgDisplay.getSize();
- }
-
- /**
- * Sets if the scrolling is to be done by copying and redrawing of damaged
- * parts of the displayed image. Otherwise it is done by redrawing the
- * entire displayed image. In general copy scrolling is faster and
- * produces less annoying effects. See the class description.
- *
- * @param v If true scrolling will be done by copying.
- * */
- public synchronized void setCopyScroll(boolean v) {
- copyScroll = v;
- }
-
- /**
- * Returns true if the scrolling is done by copying.
- *
- * @return If the copy is done by scrolling
- * */
- public synchronized boolean getCopyScroll() {
- return copyScroll;
- }
-
- /**
- * Causes this container to lay out its components. Most programs should
- * not call this method directly, but should invoke the validate method
- * instead.
- * */
- public synchronized void doLayout() {
- // Let's see if we should include the scrollbars or not
- if (sbType == SCROLLBARS_AS_NEEDED && imgDisplay.calcDim()) {
- Dimension sz = getSize();
- Dimension imsz = imgDisplay.getPreferredSize();
-
- if (sz.width>=imsz.width+2*INTERNAL_GAP) {
- if (sz.height>=imsz.height+2*INTERNAL_GAP) {
- // We don't need scrollbars
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- }
- else {
- // We need at least the vertical one, check again for the
- // horizontal.
- vsbar.setVisible(true);
- if (sz.width >=
- imsz.width+3*INTERNAL_GAP+SCROLLBAR_THICKNESS) {
- hsbar.setVisible(false);
- }
- else {
- hsbar.setVisible(true);
- }
- }
- }
- else {
- // We need at least the horizontal, check for the vertical
- // one.
- hsbar.setVisible(true);
- if (sz.height >=
- imsz.height+3*INTERNAL_GAP+SCROLLBAR_THICKNESS) {
- vsbar.setVisible(false);
- }
- else {
- vsbar.setVisible(true);
- }
- }
- }
- // Indicate that we are erasing the image (the doLayout() will erase)
- imgDisplay.erase = true;
- // Now do the layout
- super.doLayout();
- // Trick the lower scrollbar: if both scrollbars are showing then
- // shorten the horizontal one so that the traditional empty square
- // appears at the lower right corner. This is probably not the best
- // solution but it works.
- if (hsbar.isVisible() && vsbar.isVisible()) {
- Rectangle b = hsbar.getBounds();
- if (b.width > SCROLLBAR_THICKNESS+INTERNAL_GAP) {
- b.width -= SCROLLBAR_THICKNESS+INTERNAL_GAP;
- }
- hsbar.setBounds(b);
- }
- // We need to calculate the scrollbars with the possibly new size
- setScrollbars();
- }
-
- /**
- * Adds the specified focus listener to receive focus events from this
- * component. It is added to the image and scrollbar areas.
- *
- * @param l the focus listener
- * */
- public synchronized void addFocusListener(FocusListener l) {
- super.addFocusListener(l);
- imgDisplay.addFocusListener(l);
- hsbar.addFocusListener(l);
- vsbar.addFocusListener(l);
- }
-
- /**
- * Removes the specified focus listener so that it no longer receives
- * focus events from this component.
- *
- * @param l the focus listener
- * */
- public synchronized void removeFocusListener(FocusListener l) {
- super.removeFocusListener(l);
- imgDisplay.removeFocusListener(l);
- hsbar.removeFocusListener(l);
- vsbar.removeFocusListener(l);
- }
-
- /**
- * Adds the specified key listener to receive key events from this
- * component. It is added to the image and scrollbar areas.
- *
- * @param l the key listener
- * */
- public synchronized void addKeyListener(KeyListener l) {
- super.addKeyListener(l);
- imgDisplay.addKeyListener(l);
- hsbar.addKeyListener(l);
- vsbar.addKeyListener(l);
- }
-
- /**
- * Removes the specified key listener so that it no longer receives key
- * events from this component.
- *
- * @param l the key listener
- * */
- public synchronized void removeKeyListener(KeyListener l) {
- super.removeKeyListener(l);
- imgDisplay.removeKeyListener(l);
- hsbar.removeKeyListener(l);
- vsbar.removeKeyListener(l);
- }
-
- /**
- * Adds the specified mouse listener to receive mouse events from this
- * component. It is actually added to the image area only and not to the
- * scrollbar areas.
- *
- * @param l the mouse listener
- * */
- public synchronized void addMouseListener(MouseListener l) {
- super.addMouseListener(l);
- imgDisplay.addMouseListener(l);
- }
-
- /**
- * Removes the specified mouse listener so that it no longer receives
- * mouse events from this component.
- *
- * @param l the mouse listener
- * */
- public synchronized void removeMouseListener(MouseListener l) {
- super.removeMouseListener(l);
- imgDisplay.removeMouseListener(l);
- }
-
- /**
- * Adds the specified mouse motion listener to receive mouse motion events
- * from this component. It is actually added to the image area only and
- * not to the scrollbar areas.
- *
- * @param l the mouse motion listener
- * */
- public synchronized void addMouseMotionListener(MouseMotionListener l) {
- super.addMouseMotionListener(l);
- imgDisplay.addMouseMotionListener(l);
- }
-
- /**
- * Removes the specified mouse motion listener so that it no longer
- * receives mouse motion events from this component.
- *
- * @param l the mouse motion listener
- * */
- public synchronized void removeMouseMotionListener(MouseMotionListener l) {
- super.removeMouseMotionListener(l);
- imgDisplay.removeMouseMotionListener(l);
- }
- /**
- * Sets the background color of this component. It sets the background of
- * the 3 areas (image and scrollbars) plus the container itself.
- *
- * @param c The color to become background color for this component
- * */
- public synchronized void setBackground(Color c) {
- super.setBackground(c);
- imgDisplay.setBackground(c);
- hsbar.setBackground(c);
- vsbar.setBackground(c);
- }
-
- /**
- * Set the cursor image to a predefined cursor. It sets the cursor of the
- * image area and this container to the specified one. It does not set the
- * cursor of the scrollbars.
- *
- * @param cursor One of the constants defined by the Cursor class.
- * */
- public synchronized void setCursor(Cursor cursor) {
- super.setCursor(cursor);
- imgDisplay.setCursor(cursor);
- }
-
- /**
- * Enables or disables this component, depending on the value of the
- * parameter b. An enabled component can respond to user input and
- * generate events. Components are enabled initially by default.
- *
- * @param b If true, this component is enabled; otherwise this component
- * is disabled.
- * */
- public synchronized void setEnabled(boolean b) {
- super.setEnabled(b);
- imgDisplay.setEnabled(b);
- hsbar.setEnabled(b);
- vsbar.setEnabled(b);
- }
-
- /**
- * Sets the foreground color of this component. It sets the foreground of
- * the 3 areas (image display and scrollbars) plus this contaioner's
- * foreground.
- *
- * @param c The color to become this component's foreground color.
- * */
- public synchronized void setForeground(Color c) {
- super.setForeground(c);
- imgDisplay.setForeground(c);
- hsbar.setForeground(c);
- vsbar.setForeground(c);
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(String name,Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(Component comp, int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public void add(Component comp, Object constraints) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public void add(Component comp, Object constraints, int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void remove(int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void remove(Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void removeAll() {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the layout manager is
- * internally set and can not be changed.
- * */
- public void setLayout(LayoutManager mgr) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Sets the scrollbars values, according to the image display area and
- * image size. The current scroll position is kept.
- *
- * */
- private void setScrollbars() {
- Dimension asz; // actual image area size
- Dimension psz; // preferred size
- int pos; // current scroll position
- int szx,szy; // actual image display area size
-
- if (!imgDisplay.calcDim()) {
- // While the image dimensions are not known we can't really update
- // the scrollbar.
- return;
- }
-
- // Get the dimensions
- asz = imgDisplay.getSize();
- psz = imgDisplay.getPreferredSize();
-
- // Initialize lastZoom and lastSize if never done yet
- if (lastZoom == 0f) lastZoom = zoom;
- if (lastSize == null) lastSize = new Dimension(asz.width,asz.height);
-
- // Get the actual display size
- szx = (asz.width < psz.width) ? asz.width : psz.width;
- szy = (asz.height < psz.height) ? asz.height : psz.height;
-
- // Set horizontal scrollbar
- pos = (int)((hsbar.getValue()+lastSize.width/2f)/lastZoom*zoom-szx/2f);
- if (pos > (psz.width-asz.width)) pos = psz.width-asz.width;
- if (pos < 0) pos = 0;
- if (asz.width <= 0) asz.width = 1;
- if (psz.width <= 0) psz.width = 1;
- hsbar.setValues(pos,asz.width,0,psz.width);
- asz.width = (int)(asz.width*BLOCK_INCREMENT_PROPORTION);
- if (asz.width <= 0) asz.width = 1;
- hsbar.setBlockIncrementI(asz.width);
-
- // Set vertical scrollbar
- pos = (int)((vsbar.getValue()+lastSize.height/2f)/lastZoom*zoom-szy/2f);
- if (pos > (psz.height-asz.height)) pos = psz.height-asz.height;
- if (pos < 0) pos = 0;
- if (asz.height <= 0) asz.height = 1;
- if (psz.height <= 0) psz.height = 1;
- vsbar.setValues(pos,asz.height,0,psz.height);
- asz.height = (int)(asz.height*BLOCK_INCREMENT_PROPORTION);
- if (asz.height <= 0) asz.height = 1;
- vsbar.setBlockIncrementI(asz.height);
-
- // Save the zoom and display size used in the scrollbar calculation
- lastZoom = zoom;
- lastSize.width = szx;
- lastSize.height = szy;
- }
-
- /**
- * This class implements the component that displays the currently
- * viewable image portion inside the ImgScrollPane. It handles the
- * necessary erasing, zooming and panning.
- *
- * NOTE: extending 'Canvas' instead of 'Component' solves the
- * flickering problem of lightweight components which are in heavyweight
- * containers.
- *
- * */
- private class ImageScrollDisplay extends Canvas {
-
- /** The image to be displayed
- *
- * @serial */
- Image img;
-
- /** The preferred size for this component
- *
- * @serial */
- Dimension dim = new Dimension();
-
- /** If the current graphics context should be erased prior to drawing
- * the image. Set when the image and/or zoom factor is changed.
- *
- * @serial */
- boolean erase;
-
- /** The image dimensions, without any scaling. Set as soon as they are
- known.
- *
- * @serial */
- Dimension imgDim = new Dimension();
-
- /** The image dimension flags, as in ImageObserver. The
- * ImageObserver.WIDTH and ImageObserver.HEIGHT flags are set whenever
- * the dimension is stored in imgDim. They are reset whenever the
- * image changes.
- *
- * @serial */
- int dimFlags;
-
- /** The last offset used in update().
- *
- * @serial */
- Point lastUpdateOffset;
-
- /**
- * Sets the image to display in this component. If the image is not
- * ready for display it will be prepared in the current thread. The
- * current zoom factor applies.
- *
- * If the image is not ready for display (i.e. it has not been
- * rendered at its natural size) it will be rendered in the current
- * thread, if not being already rendered in another one. This means
- * that the current thread can block until the image is ready.
- *
- * If the image is rendered incrementally (it depends on the
- * underlying 'ImageProducer') it will be displayed in that way if the
- * incremental display is set for the Component class. See the
- * 'imageUpdate()' method of the 'Component' class.
- *
- * If the image is the same as the current one nothing is done.
- *
- * @param img The image to display.
- *
- * @see Component#imageUpdate
- *
- * */
- void setImage(Image img) {
- // Update object state
- synchronized (ImgScrollPane.this) {
- if (img == null) {
- throw new IllegalArgumentException();
- }
- // If same image do nothing
- if (this.img == img) {
- return;
- }
-
- // (Re)initialize
- dimFlags = 0;
- this.img = img;
- lastSize = null;
- lastZoom = 0f;
- setScrollbars();
- // Set to erase previous image
- erase = true;
- }
- // Start image production (if the image is already being prepared
- // the method does nothing)
- ImgScrollPane.this.prepareImage(img,this);
- }
-
- /**
- * Returns the minimum size for this component, which is (0,0).
- *
- * @return The minimum size
- *
- * */
- public Dimension getMinimumSize() {
- return new Dimension(0,0);
- }
-
- /**
- * Returns the maximum size for this component, which is infinite.
- *
- * @return The maximum size
- *
- * */
- public Dimension getMaximumSize() {
- return new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE);
- }
-
- /**
- * Returns the preferred size for this component, which is the image
- * display size, if known, the previous image display size, if any, or
- * the size specified at the constructor.
- *
- * @return The preferred size for this component.
- *
- * */
- public Dimension getPreferredSize() {
- return dim;
- }
-
- /**
- * Monitors the image rendering for dimensions and calls the
- * superclass' 'imageUpdate()' method. If the display size of the
- * image is not yet known and the image dimensions are obtained, then
- * the scrollbars' values are set. If 'img' is not the current image
- * to display nothing is done and 'false' is returned indicating that
- * nothing more is necessary for it.
- *
- * @see ImageObserver#imageUpdate
- *
- * @see Component#imageUpdate
- *
- * */
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int w, int h) {
- if (this.img != img) {
- // Not the image we want to display now (might be an old one)
- // => do nothing and no more info needed on that image
- return false;
- }
- // If got the image dimensions then store them and set component
- // size as appropriate.
- if ((infoflags & (ImageObserver.WIDTH|ImageObserver.HEIGHT)) != 0) {
- // Got some image dimension
- synchronized (ImgScrollPane.this) {
- // Read the dimensions received
- if ((infoflags & ImageObserver.WIDTH) != 0) {
- imgDim.width = w;
- dimFlags |= ImageObserver.WIDTH;
- }
- if ((infoflags & ImageObserver.HEIGHT) != 0) {
- imgDim.height = h;
- dimFlags |= ImageObserver.HEIGHT;
- }
- // If we got to know the image dimensions force the layout
- // to be done (to see if it is necessary to show
- // scrollbars)
- if (dimFlags ==
- (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- ImgScrollPane.this.doLayout();
- }
- }
- }
- // Call the superclass' method to continue processing
- return super.imageUpdate(img,infoflags,x,y,w,h);
- }
-
- /**
- * Paints the image, if any, on the graphics context by calling
- * update().
- *
- * @param g The graphics context to paint on.
- *
- * */
- public void paint(Graphics g) {
- // Now call update as usual
- update(g);
- }
-
- /**
- * Updates the component by drawing the relevant part of the image
- * that fits within the Graphics clipping area of 'g'. If the image is
- * not already being prepared for rendering or is not already rendered
- * this method does not start it. This is to avoid blocking the AWT
- * threads for rendering the image. The image rendering is started by
- * the 'setImage()' method.
- *
- * @param g The graphics context where to draw
- *
- * @see #setImage
- *
- * */
- public void update(Graphics g) {
- Image img; // The image to display
- float zoom; // The zoom factor
- boolean erase; // If the display area should be erased
- int dx1,dy1; // Scaling destionation upper-left corner
- int dx2,dy2; // Scaling destination down-right corner
- int sx1,sy1; // Scaling source upper-left corner
- int sx2,sy2; // Scaling source down-right corner
- int ox,oy; // Centering offset
- Rectangle b; // Bounds of the display area
- int offx,offy; // Offset of the upper-left corner
- int loffx,loffy; // Offset of the upper-left corner of last update
- boolean copyScroll;// If the scrolling should be done by copying
- Rectangle clip; // The clipping area
- int status; // The image fetching status
-
- // Copy to local variables in a synchronized block to avoid races
- synchronized (ImgScrollPane.this) {
- img = this.img;
- zoom = ImgScrollPane.this.zoom;
- erase = this.erase;
- copyScroll = ImgScrollPane.this.copyScroll;
- this.erase = false;
-
- // If no image or the image has not started preparation yet do
- // nothing. We do not want to start the image preparation in
- // this thread because it can be long.
- if (img == null || (status = this.checkImage(img,null)) == 0) {
- return;
- }
- // Get the display size and eventual centering offset for the
- // image.
- b = this.getBounds();
- ox = (b.width > dim.width) ? (b.width-dim.width)/2 : 0;
- oy = (b.height > dim.height) ? (b.height-dim.height)/2 : 0;
- // Get the display offset
- clip = g.getClipBounds();
- if (lastUpdateOffset != null &&
- (clip.width < b.width || clip.height < b.height)) {
- // The clip is smaller than the display area => we need to
- // paint with the last offset to avoid screwing up the
- // displayed image.
- offx = lastUpdateOffset.x;
- offy = lastUpdateOffset.y;
- }
- else {
- // The clipping area covers the whole display area => we
- // can use the current offset.
- offx = hsbar.getValue();
- offy = vsbar.getValue();
- }
- // Get and update the offset of last update
- if (lastUpdateOffset == null) {
- lastUpdateOffset = new Point();
- }
- loffx = lastUpdateOffset.x;
- loffy = lastUpdateOffset.y;
- lastUpdateOffset.x = offx;
- lastUpdateOffset.y = offy;
- // Set the display size according to zoom
- if (zoom == 1f) {
- // Natural image size, no scaling
- // Displace the origin of the image according to offset
- ox -= offx;
- oy -= offy;
- // No zoom so no translation for scaling compensation needed
- sx1 = sy1 = 0; // to keep compiler happy
- sx2 = sy2 = 0; // to keep compiler happy
- dx1 = dy1 = 0; // to keep compiler happy
- dx2 = dy2 = 0; // to keep compiler happy
- }
- else {
- int sox,soy; // Scaling compensation offset
- // Calculate coordinates of lower right corner for scaling
- if (dimFlags !=
- (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- // Image dims not yet available we can't display
- return;
- }
- sx1 = sy1 = 0;
- sx2 = imgDim.width;
- sy2 = imgDim.height;
- dx1 = dy1 = 0;
- dx2 = dim.width;
- dy2 = dim.height;
- sox = soy = 0;
- // Limit the scaling area according to display size so
- // that scaling operates only on the area to be displayed
- if (dx2 > b.width) {
- // Calculate coordinates of displayed portion
- dx2 = b.width+ ((zoom>1f) ? (int)Math.ceil(zoom) : 0);
- if ((int)zoom == zoom) {
- // For integer zoom make dx2 a multiple of zoom
- dx2 = (int)(Math.ceil(dx2/zoom)*zoom);
- }
- sx1 = (int)(offx/zoom);
- sx2 = sx1 + (int)(dx2/zoom);
- // Compensate the scaling on integer coordinates with
- // an offset
- sox = (int)(sx1*zoom-offx);
- }
- if (dy2 > b.height) {
- // Calculate coordinates of displayed portion
- dy2 = b.height + ((zoom>1f) ? (int)Math.ceil(zoom) : 0);
- if ((int)zoom == zoom) {
- // For integer zoom make dy2 a multiple of zoom
- dy2 = (int)(Math.ceil(dy2/zoom)*zoom);
- }
- sy1 = (int)(offy/zoom);
- sy2 = sy1 + (int)(dy2/zoom);
- // Compensate the scaling on integer coordinates with
- // an extra offset
- soy = (int)(sy1*zoom-offy);
- }
- // Apply centering offset and scaling compensation offset
- dx1 += ox + sox;
- dy1 += oy + soy;
- dx2 += ox + sox;
- dy2 += oy + soy;
- }
- }
- // If the image is not yet complete and we are scrolling set to
- // erase to avoid leftovers of previous scroll on parts of the
- // image which are not yet ready
- if ((status & ImageObserver.ALLBITS) == 0 &&
- (loffx != offx || loffy != offy)) {
- erase = true;
- }
- // Now we have the necessary info for display. We do it outside
- // synchronized to avoid any potential deadlocks with imageUpdate().
- if (erase) {
- // We need to erase the current image. Make sure that we
- // redraw everything by setting the clipping area to the whole
- // display one.
- g.setClip(0,0,b.width,b.height);
- g.setColor(this.getBackground());
- g.fillRect(0,0,b.width,b.height);
- }
-
- // Use copy scrolling if the image has not been erased, we are
- // scrolling, the image is complete, and copy scrolling is enabled.
- if (copyScroll && !erase && (loffx != offx || loffy != offy) &&
- (status & ImageObserver.ALLBITS) != 0) {
- // We might be able to move some part of the displayed area
- // instead of redrawing everything.
-
- // We are just trasnlating the current image, so we can reuse
- // a part of it.
-
- int culx,culy; // Clipping area upper-left corner (inclusive)
- int cdrx,cdry; // Clipping area down-right corner (exclusive)
- int vulx,vuly; // Valid area upper-left corner (inclusive)
- int vdrx,vdry; // Valid area down-right corner (exclusive)
-
- culx = clip.x;
- culy = clip.y;
- cdrx = clip.x+clip.width;
- cdry = clip.y+clip.height;
-
- // Initialize valid area as the current display area after the
- // translation.
- vulx = loffx-offx;
- vuly = loffy-offy;
- vdrx = vulx+b.width;
- vdry = vuly+b.height;
-
- // Make new valid area the intersection of the clipping area
- // and the valid area.
- if (culx > vulx) vulx = culx;
- if (culy > vuly) vuly = culy;
- if (cdrx < vdrx) vdrx = cdrx;
- if (cdry < vdry) vdry = cdry;
-
- // If the new valid area is non-empty then copy current image
- // data
- if (vulx < vdrx && vuly < vdry) {
- // Ok we can move a part instead of repainting
- g.copyArea(vulx+offx-loffx,vuly+offy-loffy,
- vdrx-vulx,vdry-vuly,
- loffx-offx,loffy-offy);
- // Now we need to redraw the other parts
- if (culx < vulx) { // Need to draw at left
- g.setClip(culx,culy,vulx-culx,cdry-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (vdrx < cdrx) { // Need to draw at right
- g.setClip(vdrx,culy,cdrx-vdrx,cdry-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (culy < vuly) { // Need to draw at top
- g.setClip(vulx,culy,vdrx-vulx,vuly-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (vdry < cdry) { // Need to draw at bottom
- g.setClip(vulx,vdry,vdrx-vulx,cdry-vdry);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- }
- else {
- // New valid area is empty, we need to draw everything
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,this);
- }
- }
- }
- else {
- // We are not translating, so we can't copy
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,this);
- }
- }
- }
-
- /**
- * Calculates the image display dimensions according to the zoom and
- * image size. The dimensions are stored in 'dim'.
- *
- * @return True if the dimensions could be calculated, false if not
- * (i.e. not enough info is available).
- *
- * */
- boolean calcDim() {
- // We need the image dimensions
- if (dimFlags != (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- // Image dims not yet available we can't do anything
- return false;
- }
- // Calculate dims
- if (zoom == 1f) {
- // Natural image dimension
- dim.width = imgDim.width;
- dim.height = imgDim.height;
- }
- else {
- // Apply zoom
- dim.width = (int)(zoom*imgDim.width);
- dim.height = (int)(zoom*imgDim.height);
- }
- return true;
- }
- }
-
- /**
- * Scrollbars for the ImgScrollPane container. They are normal AWT
- * Scrollbars, but with a thickness of
- * ImgScrollPane.SCROLLBAR_THICKNESS. Also many of the set method of the
- * Adjustable interface are overriden and throw IllegalArgumentException
- * since they are not to be used externally.
- *
- * */
- class ISPScrollbar extends Scrollbar {
-
- /**
- * Constructs a new scroll bar with the specified orientation and
- * values.
- *
- * The orientation argument must take one of the two values
- * Scrollbar.HORIZONTAL, or Scrollbar.VERTICAL, indicating a
- * horizontal or vertical scroll bar, respectively.
- *
- * @param orientation indicates the orientation of the scroll bar
- *
- * @param value the initial value of the scroll bar.
- *
- * @param visible the size of the scroll bar's bubble, representing
- * the visible portion; the scroll bar uses this value when paging up
- * or down by a page.
- *
- * @param min the minimum value of the scroll bar.
- *
- * @param max the maximum value of the scroll bar.
- *
- * @param svt The scrollbar visible type
- **/
- ISPScrollbar(int orientation,
- int value, int visible, int min, int max) {
- super(orientation,value,visible,min,max);
- }
-
- /**
- * Returns the preferred size of the scrollbar. It is the same as the
- * preferred size of a normal scrollbar but with a thickness of
- * ImgScrollPane.SCROLLBAR_THICKNESS.
- *
- * @return The Scrollbar preferred size
- * */
- public Dimension getPreferredSize() {
- Dimension psz = super.getPreferredSize();
- if (getOrientation() == HORIZONTAL) {
- psz.height = ImgScrollPane.SCROLLBAR_THICKNESS;
- }
- else {
- psz.width = ImgScrollPane.SCROLLBAR_THICKNESS;
- }
- return psz;
- }
-
- /**
- * Throws an IllegalArgumentException since the minimum value should
- * never be set externally.
- * */
- public void setMinimum(int min) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the maximum value should
- * never be set externally.
- * */
- public void setMaximum(int max) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the visible amount should
- * never be set externally.
- * */
- public void setVisibleAmount(int v) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the block increment should
- * never be set externally.
- * */
- public void setBlockIncrement(int b) {
- super.setBlockIncrement(b);
- }
-
- /**
- * Sets the block increment for this scroll bar.
- *
- * The block increment is the value that is added (subtracted) when
- * the user activates the block increment area of the scroll bar,
- * generally through a mouse or keyboard gesture that the scroll bar
- * receives as an adjustment event.
- *
- * This is a version to be used by The ImgScrollPane class only.
- *
- * @param v the amount by which to increment or decrement the scroll
- * bar's value.
- * */
- void setBlockIncrementI(int v) {
- super.setBlockIncrement(v);
- }
-
- /**
- * Sets the value of this scroll bar to the specified value.
- *
- * If the value supplied is less than the current minimum or
- * greater than the current maximum, then one of those values is
- * substituted, as appropriate.
- *
- * This is a version to be used by The ImgScrollPane class only.
- *
- * @param newValue he new value of the scroll bar.
- * */
- void setValueI(int newValue) {
- super.setValue(newValue);
- }
-
- /**
- * Sets the value of this scroll bar to the specified value and
- * requests a repaint of the image area.
- *
- * If the value supplied is less than the current minimum or
- * greater than the current maximum, then one of those values is
- * substituted, as appropriate.
- *
- * @param newValue he new value of the scroll bar.
- * */
- public void setValue(int newValue) {
- // Set the value and check if we need to repaint
- synchronized (ImgScrollPane.this) {
- super.setValue(newValue);
- newValue = getValue(); // get the actual value for check
- if (imgDisplay.lastUpdateOffset != null) {
- if (getOrientation() == HORIZONTAL) {
- if (imgDisplay.lastUpdateOffset.x == newValue) {
- return; // No change
- }
- }
- else {
- if (imgDisplay.lastUpdateOffset.y == newValue) {
- return; // No change
- }
- }
- }
- }
- // New value changes from last drawn => repaint
- imgDisplay.repaint();
- }
- }
-}
diff --git a/CSJ2K/jj2kdecoder/disp/TitleUpdater.jsl b/CSJ2K/jj2kdecoder/disp/TitleUpdater.jsl
deleted file mode 100644
index 7eafe69e..00000000
--- a/CSJ2K/jj2kdecoder/disp/TitleUpdater.jsl
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * CVS identifier:
- *
- * $Id: TitleUpdater.java,v 1.8 2002/06/24 14:04:58 grosbois Exp $
- *
- * Class: TitleUpdater
- *
- * Description: Thread to update display window title
- *
- *
- *
- * COPYRIGHT:
- *
- * This software module was originally developed by Raphaël Grosbois and
- * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
- * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
- * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
- * Centre France S.A) in the course of development of the JPEG2000
- * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
- * software module is an implementation of a part of the JPEG 2000
- * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
- * Systems AB and Canon Research Centre France S.A (collectively JJ2000
- * Partners) agree not to assert against ISO/IEC and users of the JPEG
- * 2000 Standard (Users) any of their rights under the copyright, not
- * including other intellectual property rights, for this software module
- * with respect to the usage by ISO/IEC and Users of this software module
- * or modifications thereof for use in hardware or software products
- * claiming conformance to the JPEG 2000 Standard. Those intending to use
- * this software module in hardware or software products are advised that
- * their use may infringe existing patents. The original developers of
- * this software module, JJ2000 Partners and ISO/IEC assume no liability
- * for use of this software module or modifications thereof. No license
- * or right to this software module is granted for non JPEG 2000 Standard
- * conforming products. JJ2000 Partners have full right to use this
- * software module for his/her own purpose, assign or donate this
- * software module to any third party and to inhibit third parties from
- * using this software module for non JPEG 2000 Standard conforming
- * products. This copyright notice must be included in all copies or
- * derivative works of this software module.
- *
- * Copyright (c) 1999/2000 JJ2000 Partners.
- * */
-package CSJ2K.disp;
-
-import java.awt.*;
-
-/**
- * This class should run as an independent thread to update tha main
- * display window title with current image scroll position and
- * zoom.
- * */
-public class TitleUpdater implements Runnable {
-
- /** The update perion, in milliseconds: 100 */
- static final int UPDATE_T = 100;
-
- /** The ImgScrollPane where the image is displayed */
- ImgScrollPane isp;
-
- /** The frame which title to update */
- Frame win;
-
- /** The base of the title */
- String btitle;
-
- /** The thread exits when this is true */
- volatile public boolean done = false;
-
- /**
- * Instantiates the title updater. The title of 'win' will be
- * regularly updated with the current zoom and scroll point. The
- * current zoom and scroll point are added to the basic title
- * given by 'btitle'.
- *
- * @param isp Where the image is displayed
- *
- * @param win The window which title to update
- *
- * @param btitle The base of the title.
- * */
- public TitleUpdater(ImgScrollPane isp, Frame win, String btitle) {
- this.isp = isp;
- this.win = win;
- this.btitle = btitle;
- }
-
- /**
- * The method that executes this thread. The method periodically
- * updates the title, if necessary, and puts to sleep the thread
- * for 100 msec. This method never returns. If the sleep of the
- * thread is interrupted, the title will be updated earlier and
- * the cycle will continue.
- * */
- public void run() {
- // Periodically update the window title
- Point lsp,sp;
- float lzf,zf;
- lsp = isp.getScrollPosition();
- lzf = isp.getZoom();
- while (!done) {
- sp = isp.getScrollPosition();
- zf = isp.getZoom();
- // Update title only if necessary
- if (zf != lzf || !sp.equals(lsp)) {
- win.setTitle(btitle+
- " @ ("+(int)(sp.x/zf)+","+
- (int)(sp.y/zf)+") : "+isp.getZoom());
- }
- lsp = sp;
- lzf = zf;
- try {
- Thread.currentThread().sleep(UPDATE_T);
- }
- catch (InterruptedException e) {
- }
- }
- }
-}
diff --git a/CSJ2K/jj2kdecoder/j2kdecoder.vjsproj b/CSJ2K/jj2kdecoder/j2kdecoder.vjsproj
deleted file mode 100644
index ecb180fc..00000000
--- a/CSJ2K/jj2kdecoder/j2kdecoder.vjsproj
+++ /dev/null
@@ -1,61 +0,0 @@
- First the encoder should be initialized with a ParameterList object
- * provided through the constructor. Then, the run() method is invoked and the
- * encoder executes. The exit code of the class can be obtained with the
- * getExitCode() method, after the constructor and after the run method. A
- * non-zero value indicates that an error has occurred. The modules are inserted in the encoding chain with the following
- * order: The encoder uses a pull model. This means that the last module
- * (PostCompRateAllocator) requests data from its source (EntropyCoder),
- * ... Writing of the codestream writing (header+bit stream) is realized by
- * HeaderEncoder and CodestreamWriter modules. Packed packet headers and file-format creation are carried out by
- * CodestreamManipulator and FileFormatWriter modules respectively. Many modules of the encoder may behave differently depending on the
- * tile-component. The specifications of their behaviour are kept in
- * specialized modules extending ModuleSpec class. All these modules are
- * accessible through an instance of EncoderSpecs class. BlkImgDataSrc sources with 1, 3 and 4 components are supported. If 1, it
- * is assumed to be gray-level data. If 3 it is assumed to be RGB data, in
- * that order. If 4 it is assumed to be RGBA data (RGB plus alpha plane), in
- * that order. All components must have the same size. This method uses the JVM default Toolkit, which might not be what it
- * is desired. This method uses the component's toolkit. The toolkit of a component
- * may change if it is moved from one frame to another one, since it is
- * the frame that controls which toolkit is used. Delivery is performed in "parallel" to all the registered image
- * consumers. By "parallel" it is meant that each line of the image is
- * delivered to all consumers before delivering the next line. If the data returned by the BlkImgDataSrc source happens to be
- * progressive (see BlkImgDataSrc and DataBlk) then the abort condition is
- * sent to the image consumers and no further data is delivered. Once all the data is sent to a consumer this one is automatically
- * removed from the list of registered ones, unless an abort happens. To start the BlkImgDataSrc is set to tile (0,0), and the tiles are
- * produced in raster sacn order. Once the last tile is produced,
- * setTile(0,0) is called again, which signals that we are done with the
- * current tile, which might free up resources. Currently this call is ignored (which is perfectly legal according
- * to the ImageProducer interface specification). The following key sequences are defined:
- * The amount by which the arrows scroll the image is determined by the
- * modifier keys. If the Ctrl key is held down, the block increment will be
- * used, otherwise the unit increment will. If the Shift key is held down then
- * the increment is multiplied by ACCEL_FACTOR. That is the Ctrl key selects
- * between unit and block increments, while the Shift key selects between
- * normal and accelerated mode.
- *
- * */
-public class ImgKeyListener extends KeyAdapter {
-
- /** Frame used to display tools */
- Frame helpFrame = null;
-
- /** The component where the image is displayed */
- ImgScrollPane isp;
-
- /** Decoder instance */
- Decoder dec;
-
- /** The acceleration factor when the shift key is pressed: 10 */
- public static final int ACCEL_FACTOR = 10;
-
- /**
- * Instantiate a new ImgKeyListener that will work on the specified
- * ImgScrollPane.
- *
- * @param isp The image scroll pane on which the actions should
- * operate.
- *
- * @param dec The decoder instance
- * */
- public ImgKeyListener(ImgScrollPane isp,Decoder dec) {
- this.isp = isp;
- this.dec = dec;
- }
-
- /**
- * Hanldes the keyPressed events. Normal keys are not treated here because
- * some don't have a defined keycode (as incredible as it might seem!).
- *
- * @param evt The key event to process.
- * */
- public void keyPressed(KeyEvent evt) {
- Adjustable adj;
-
- // Do nothing if consumed
- if (evt.isConsumed()) return;
-
- // Perform action based on key
- switch (evt.getKeyCode()) {
- case KeyEvent.VK_LEFT: // Move left
- adj = isp.getHAdjustable();
- adj.setValue(adj.getValue()-calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_RIGHT: // Move right
- adj = isp.getHAdjustable();
- adj.setValue(adj.getValue()+calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_UP: // Move up
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()-calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_DOWN: // Move down
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()+calcIncrement(evt,adj));
- break;
- case KeyEvent.VK_PAGE_UP: // Move up by a page
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()-adj.getBlockIncrement());
- break;
- case KeyEvent.VK_PAGE_DOWN: // Move down by a page
- adj = isp.getVAdjustable();
- adj.setValue(adj.getValue()+adj.getBlockIncrement());
- break;
- case KeyEvent.VK_C:
- // Exit if ctrl is pressed
- if (evt.isControlDown()) {
- dec.exit();
- }
- break;
- default:
- return;
- }
-
- // Consume the event so nothing else is done
- evt.consume();
- }
-
- /**
- * Handles the key typed event. Normal (i.e. "text") keys are handled
- * here.
- *
- * @param evt The key event to process.
- * */
- public void keyTyped(KeyEvent evt) {
-
- // Do nothing if consumed
- if (evt.isConsumed()) return;
-
- // Perform action based on key
- switch (evt.getKeyChar()) {
- case '+':
- case '=':
- // Zoom in
- isp.zoom(2f);
- break;
- case '-':
- // Zoom out
- isp.zoom(0.5f);
- break;
- case '1':
- // Set zoom to 1
- isp.setZoom(1f);
- break;
- case 'q':
- case 'Q':
- // Exit
- dec.exit();
- break;
- case 'h':
- case 'H':
- // Help display
- if(helpFrame==null){
- helpFrame = new Frame("Tools");
- helpFrame.add(getHelp());
- helpFrame.pack();
- helpFrame.setResizable(false);
- helpFrame.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- helpFrame.setVisible(false);
- }
- });
- }
- if(helpFrame.isVisible())
- helpFrame.setVisible(false);
- else
- helpFrame.setVisible(true);
- break;
- default:
- return;
- }
-
- // Consume the event so nothing else is done
- evt.consume();
- }
-
- /**
- * Returns the increment based on the modifier keys of the KeyEvent. If
- * control is down then the Adjustable block increment is used, otherwise
- * the unit one is used. If the shift key is down the increment is
- * multiplied by ACCEL_FACTOR.
- *
- * @param evt The KeyEvent fom where to obtain the modifiers
- *
- * @param adj The Adjustable from where to obtain the increments
- * */
- private int calcIncrement(KeyEvent evt, Adjustable adj) {
- int incr;
- // Control selects block instead of unit
- if (evt.isControlDown()) {
- incr = adj.getBlockIncrement();
- }
- else {
- incr = adj.getUnitIncrement();
- }
- // Shift accelerates by ACCEL_FACTOR
- if (evt.isShiftDown()) {
- incr *= ACCEL_FACTOR;
- }
- return incr;
- }
-
- /**
- * Create a help TextArea concerning the tools associated with keys.
- *
- * @return The help TextArea
- *
- */
- private static TextArea getHelp(){
- TextArea ta = new TextArea("",17,61,TextArea.SCROLLBARS_NONE);
- ta.setEditable(false);
- ta.setFont(new Font("Monospaced",Font.PLAIN,10));
-
- ta.append("The following key sequences are recognized in the \n"+
- "image display window:\n\n");
- ta.append("'-' : zoom out by a factor of 2.\n");
- ta.append("'+' or '=' : zoom in by a factor of 2.\n");
- ta.append("'1' : set the zoom factor to 1 (i.e. no zoom).\n");
- ta.append(" Objects of this class must be registerd as both mouse listener and mouse
- * motion listener.
- *
- * While the dragging is taking place the cursor is changed to the
- * MOVE_CURSOR type. The original cursor is restored when the mouse is
- * released after the drag.
- *
- * */
-public class ImgMouseListener extends MouseAdapter
- implements MouseMotionListener {
- /** The component where the image is displayed */
- ImgScrollPane isp;
-
- /** The horizontal coordinate where the drag starts */
- int startMouseX;
-
- /** The vertical coordinate where the drag starts */
- int startMouseY;
-
- /** The horizontal scroll position when the drag started */
- int startScrollX;
-
- /** The vertical scroll position when the drag started */
- int startScrollY;
-
- Cursor prevCursor;
-
- /**
- * Instantiate a new ImgMouseListener that will work on the specified
- * ImgScrollPane.
- *
- * @param isp The image scroll pane on which the actions should operate.
- * */
- public ImgMouseListener(ImgScrollPane isp) {
- this.isp = isp;
- }
-
- public void mousePressed(MouseEvent e) {
- // Get the possibly start drag position
- startMouseX = e.getX();
- startMouseY = e.getY();
- // Get the start scroll position
- startScrollX = isp.getHAdjustable().getValue();
- startScrollY = isp.getVAdjustable().getValue();
- }
-
- public void mouseReleased(MouseEvent e) {
- // Restore the last cursor, if any
- if (prevCursor != null) {
- isp.setCursor(prevCursor);
- prevCursor = null;
- }
- }
-
- public void mouseDragged(MouseEvent evt) {
- int scrollX,scrollY;
-
- // Set the drag cursor
- if (prevCursor == null) {
- prevCursor = isp.getCursor();
- isp.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
- }
-
- // Calculate new scroll position and set it
- scrollX = startScrollX + startMouseX - evt.getX();
- scrollY = startScrollY + startMouseY - evt.getY();
- isp.setScrollPosition(scrollX,scrollY);
- }
-
- public void mouseMoved(MouseEvent evt) {
- }
-}
diff --git a/CSJ2K/jj2kencoder/disp/ImgScrollPane.jsl b/CSJ2K/jj2kencoder/disp/ImgScrollPane.jsl
deleted file mode 100644
index 62a72bd6..00000000
--- a/CSJ2K/jj2kencoder/disp/ImgScrollPane.jsl
+++ /dev/null
@@ -1,1402 +0,0 @@
-/*
- * CVS identifier:
- *
- * $Id: ImgScrollPane.java,v 1.10 2000/12/04 17:19:27 grosbois Exp $
- *
- * Class: ImgScrollPane
- *
- * Description: The zoom factor by default is 1. It can be changed with the 'zoom()' and
- * 'setZoom()' methods. The maximum zoom factor is defined by MAX_ZOOM.
- *
- * The zoom scaling is done directly by the AWT display system. In general
- * it is performed by dropping or repeating lines. It is just intended to
- * provide a display zoom and not for proper scaling of an image.
- *
- * The scrolling can be performed by copying the actual displayed data to
- * the new scrolled position and redrawing the damaged parts, or by redrawing
- * the entire displayed image portion at the new scrolled position. Which is
- * more efficient depends on the JVM and working environment. By default it is
- * done by copying since it tends to provide less annoying visual artifacts
- * while scrolling, but that can be changed with 'setCopyScroll()'.
- *
- * This class is very similar to the AWT ScrollPane one, but it is
- * optimized for display of large images and does not suffer from the problems
- * of ScrollPane when changing zoom. The Adjustable elements that represent
- * the scrollbars are made available as in ScrollPane, but the minimum,
- * maximum, visible amount and block increment should not be set
- * (IllegalArgumentException is thrown if attempted), since they are set
- * internally by this class.
- *
- * Focus and key event listeners that are registered are in fact registered
- * with the components that implement the three areas (the image display and
- * the two scrollbars) so that if any such event is fired in any of these
- * areas it is handled by the registered listener.
- *
- * Mouse and mouse movement event listeners that are registered are in fact
- * registered with the image display component only. The mouse and mouse
- * movement events on the scrollbars are handled by the Scrollbar default
- * listeners only.
- *
- * Although it is implemented as a container, it behaves like a
- * component. Specifically no components can be added or removed from objects
- * of this class. Furthermore, no layout manager can be set. It is internally
- * set and it can not be changed.
- *
- * The implementation uses a lightweight container with an inner class to
- * display the image itself, and two scrollbars. The layout manager is a
- * BorderLayout.
- *
- * This class should be really implemented as a Component, but it is
- * implemented as a Container for easyness. It should not be assumed it is a
- * subclass of Container since in the future it might be rewritten as a
- * subclass of Component only.
- *
- *
- * @see ScrollPane
- *
- * @see Adjustable
- * */
-public class ImgScrollPane extends Container {
-
- /** The ID for always visible scrollbars */
- public final static int SCROLLBARS_ALWAYS = ScrollPane.SCROLLBARS_ALWAYS;
-
- /** The ID for as needed visible scrollbars */
- public final static int SCROLLBARS_AS_NEEDED =
- ScrollPane.SCROLLBARS_AS_NEEDED;
-
- /** The ID for never visible scrollbars */
- public final static int SCROLLBARS_NEVER = ScrollPane.SCROLLBARS_NEVER;
-
- /** The maximum possible zoom factor: 32. */
- // This is used because factors too large cause problems with JVMs.
- public static final float MAX_ZOOM = 32f;
-
- /** The thickness of the scrollbars: 16 pixels */
- final static int SCROLLBAR_THICKNESS = 16;
-
- /** The inetrnal gap between the elements, in pixels: 0 */
- final static int INTERNAL_GAP = 0;
-
- /** The propertion between the visible scrollbar length and the block
- * increment amount: 0.8 */
- final static float BLOCK_INCREMENT_PROPORTION = 0.8f;
-
- /** The horizontal scrollbar.
- *
- * @serial
- */
- ISPScrollbar hsbar;
-
- /** The vertical scrollabr.
- *
- * @serial
- */
- ISPScrollbar vsbar;
-
- /** The image display
- *
- * @serial
- */
- private ImageScrollDisplay imgDisplay;
-
- /** The scrollbar type (always, as needed, etc.)
- *
- * @serial
- */
- private int sbType;
-
- /** The zoom to use in displaying the image. A factor larger than one
- * produces a zoom in effect.
- *
- * @serial
- */
- private float zoom = 1f;
-
- /** The zoom used in the last scrollbar calculation.
- *
- * @serial
- */
- private float lastZoom;
-
- /** The viewable size used in the last scrollbar calculation.
- *
- * @serial
- */
- private Dimension lastSize;
-
- /** If scrolling is to be done by copying ot not. If not done by copying
- * everything is redrawn.
- *
- * @serial*/
- private boolean copyScroll = true;
-
- /**
- * Creates a new ImgScrollPane with SCROLLBARS_AS_NEEDED scrollbars.
- * */
- public ImgScrollPane() {
- this(SCROLLBARS_AS_NEEDED);
- }
-
- /**
- * Creates a new ImgScrollPane with the specified type of scrollbar
- * visibility.
- *
- * @param svt The scrollbar visibility type
- * */
- public ImgScrollPane(int svt) {
- // Initialize
- super.setLayout(new BorderLayout(INTERNAL_GAP,INTERNAL_GAP));
- sbType = svt;
- hsbar = new ISPScrollbar(Scrollbar.HORIZONTAL,0,1,0,1);
- vsbar = new ISPScrollbar(Scrollbar.VERTICAL,0,1,0,1);
- imgDisplay = new ImageScrollDisplay();
- super.add(hsbar,BorderLayout.SOUTH);
- super.add(vsbar,BorderLayout.EAST);
- super.add(imgDisplay,BorderLayout.CENTER);
-
- // Set the initial scrollbar visibility
- switch (svt) {
- case SCROLLBARS_NEVER:
- case SCROLLBARS_AS_NEEDED:
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- break;
- case SCROLLBARS_ALWAYS:
- hsbar.setVisible(true);
- vsbar.setVisible(true);
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Sets the image to display in this component. If the image is not
- * ready for display it will be prepared in the current thread. The
- * current zoom factor applies.
- *
- * If the image is not ready for display (i.e. it has not been
- * rendered at its natural size) it will be rendered in the current
- * thread, if not being already rendered in another one. This means
- * that the current thread can block until the image is ready.
- *
- * If the image is rendered incrementally (it depends on the
- * underlying 'ImageProducer') it will be displayed in that way if the
- * incremental display is set for the Component class. See the
- * 'imageUpdate()' method of the 'Component' class.
- *
- * If the image is the same as the current one nothing is done.
- *
- * @param img The image to display.
- *
- * @see Component#imageUpdate
- * */
- public void setImage(Image img) {
- imgDisplay.setImage(img);
- }
-
- /**
- * Returns the image that is displayed in this component.
- *
- * @return The image displayed in this component, or null if none.
- * */
- public synchronized Image getImage() {
- return imgDisplay.img;
- }
-
- /**
- * Sets the zoom factor to display the image. A zoom factor larger than 1
- * corresponds to a zoom in. A factor of 1 corresponds to no
- * scaling. After setting the zoom factor the component is invalidated and
- * 'repaint()' is automatically called so that the image is redrawn at the
- * new zoom factor. In order to revalidate the layout 'validate()' should
- * be called on one of the parent containers. If the new zoom factor is
- * larger than MAX_ZOOM, then MAX_ZOOM will be used.
- *
- * @param zf The zoom factor
- * */
- public synchronized void setZoom(float zf) {
- if (zf == zoom || (zf > MAX_ZOOM && zoom == MAX_ZOOM)) {
- // No change => do nothing
- return;
- }
- // Set the zoom factor and recalculate the component dimensions
- zoom = zf;
- if (zoom > MAX_ZOOM) zoom = MAX_ZOOM;
- setScrollbars();
- // Check if we need to change the scrollbar display
- if (sbType == SCROLLBARS_AS_NEEDED) doLayout();
- // We need to erase previous scaled image
- imgDisplay.erase = true;
- // Redraw image
- imgDisplay.repaint();
- }
-
- /**
- * Modifies the current zoom factor by the given multiplier. After setting
- * the zoom factor the component is invalidated and 'repaint()' is
- * automatically called so that the image is redrawn at the new zoom
- * factor. In order to revalidate the layout 'validate()' should be called
- * on one of the parent containers. If the resulting zoom factor is larger
- * than MAX_ZOOM, then MAX_ZOOM will be used.
- *
- * @param zm The zoom multiplier to apply.
- * */
- public synchronized void zoom(float zm) {
- setZoom(zoom*zm);
- }
-
- /**
- * Returns the current zoom factor.
- *
- * @return The current zoom factor
- * */
- public synchronized float getZoom() {
- return zoom;
- }
-
- /**
- * Returns the Adjustable object which represents the state of the
- * horizontal scrollbar.
- * */
- public Adjustable getHAdjustable() {
- return hsbar;
- }
-
- /**
- * Returns the Adjustable object which represents the state of the
- * vertical scrollbar.
- * */
- public Adjustable getVAdjustable() {
- return vsbar;
- }
-
- /**
- * Returns the display policy for the scrollbars.
- *
- * @return the display policy for the scrollbars
- * */
- public int getScrollbarDisplayPolicy() {
- return sbType;
- }
-
- /**
- * Sets the display policy for the scrollbars.
- *
- * @param v the display policy for the scrollbars
- * */
- public void setScrollbarDisplayPolicy(int v) {
- // If no change do nothing
- if (v == sbType) return;
- switch (sbType) {
- case SCROLLBARS_NEVER:
- case SCROLLBARS_AS_NEEDED:
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- break;
- case SCROLLBARS_ALWAYS:
- hsbar.setVisible(true);
- vsbar.setVisible(true);
- break;
- default:
- throw new IllegalArgumentException();
- }
- // Now redo the layout
- doLayout();
- }
-
- /**
- * Scrolls to the specified position within the image. Specifying a
- * position outside of the legal scrolling bounds of the image will scroll
- * to the closest legal position. This is a convenience method which
- * interfaces with the Adjustable objects which represent the state of the
- * scrollbars.
- *
- * @param x the x position to scroll to
- *
- * @param y the y position to scroll to
- * */
- public synchronized void setScrollPosition(int x, int y) {
- hsbar.setValueI(x);
- vsbar.setValueI(y);
- // Check if we need to repaint
- x = hsbar.getValue(); // get the actual value for check
- y = vsbar.getValue(); // get the actual value for check
- if (imgDisplay.lastUpdateOffset != null &&
- imgDisplay.lastUpdateOffset.x == x &&
- imgDisplay.lastUpdateOffset.y == y) {
- return; // No change
- }
- // New value changes from last drawn => repaint
- imgDisplay.repaint();
- }
-
- /**
- * Scrolls to the specified position within the image. Specifying a
- * position outside of the legal scrolling bounds of the image will scroll
- * to the closest legal position. This is a convenience method which
- * interfaces with the Adjustable objects which represent the state of the
- * scrollbars.
- *
- * @param p the position to scroll to
- * */
- public synchronized void setScrollPosition(Point p) {
- setScrollPosition(p.x,p.y);
- }
-
- /**
- * Returns the current x,y position within the child which is displayed at
- * the 0,0 location of the scrolled panel's view port. This is a
- * convenience method which interfaces with the adjustable objects which
- * represent the state of the scrollbars.
- *
- * @return the coordinate position for the current scroll position
- * */
- public Point getScrollPosition() {
- return new Point(hsbar.getValue(),vsbar.getValue());
- }
-
- /**
- * Returns the current size of the image scroll pane's view port. This is
- * the size of the image display area. If this component has not been
- * layed out yet the value is not defined.
- *
- * @return The size of the image display area
- * */
- public Dimension getViewportSize() {
- return imgDisplay.getSize();
- }
-
- /**
- * Sets if the scrolling is to be done by copying and redrawing of damaged
- * parts of the displayed image. Otherwise it is done by redrawing the
- * entire displayed image. In general copy scrolling is faster and
- * produces less annoying effects. See the class description.
- *
- * @param v If true scrolling will be done by copying.
- * */
- public synchronized void setCopyScroll(boolean v) {
- copyScroll = v;
- }
-
- /**
- * Returns true if the scrolling is done by copying.
- *
- * @return If the copy is done by scrolling
- * */
- public synchronized boolean getCopyScroll() {
- return copyScroll;
- }
-
- /**
- * Causes this container to lay out its components. Most programs should
- * not call this method directly, but should invoke the validate method
- * instead.
- * */
- public synchronized void doLayout() {
- // Let's see if we should include the scrollbars or not
- if (sbType == SCROLLBARS_AS_NEEDED && imgDisplay.calcDim()) {
- Dimension sz = getSize();
- Dimension imsz = imgDisplay.getPreferredSize();
-
- if (sz.width>=imsz.width+2*INTERNAL_GAP) {
- if (sz.height>=imsz.height+2*INTERNAL_GAP) {
- // We don't need scrollbars
- hsbar.setVisible(false);
- vsbar.setVisible(false);
- }
- else {
- // We need at least the vertical one, check again for the
- // horizontal.
- vsbar.setVisible(true);
- if (sz.width >=
- imsz.width+3*INTERNAL_GAP+SCROLLBAR_THICKNESS) {
- hsbar.setVisible(false);
- }
- else {
- hsbar.setVisible(true);
- }
- }
- }
- else {
- // We need at least the horizontal, check for the vertical
- // one.
- hsbar.setVisible(true);
- if (sz.height >=
- imsz.height+3*INTERNAL_GAP+SCROLLBAR_THICKNESS) {
- vsbar.setVisible(false);
- }
- else {
- vsbar.setVisible(true);
- }
- }
- }
- // Indicate that we are erasing the image (the doLayout() will erase)
- imgDisplay.erase = true;
- // Now do the layout
- super.doLayout();
- // Trick the lower scrollbar: if both scrollbars are showing then
- // shorten the horizontal one so that the traditional empty square
- // appears at the lower right corner. This is probably not the best
- // solution but it works.
- if (hsbar.isVisible() && vsbar.isVisible()) {
- Rectangle b = hsbar.getBounds();
- if (b.width > SCROLLBAR_THICKNESS+INTERNAL_GAP) {
- b.width -= SCROLLBAR_THICKNESS+INTERNAL_GAP;
- }
- hsbar.setBounds(b);
- }
- // We need to calculate the scrollbars with the possibly new size
- setScrollbars();
- }
-
- /**
- * Adds the specified focus listener to receive focus events from this
- * component. It is added to the image and scrollbar areas.
- *
- * @param l the focus listener
- * */
- public synchronized void addFocusListener(FocusListener l) {
- super.addFocusListener(l);
- imgDisplay.addFocusListener(l);
- hsbar.addFocusListener(l);
- vsbar.addFocusListener(l);
- }
-
- /**
- * Removes the specified focus listener so that it no longer receives
- * focus events from this component.
- *
- * @param l the focus listener
- * */
- public synchronized void removeFocusListener(FocusListener l) {
- super.removeFocusListener(l);
- imgDisplay.removeFocusListener(l);
- hsbar.removeFocusListener(l);
- vsbar.removeFocusListener(l);
- }
-
- /**
- * Adds the specified key listener to receive key events from this
- * component. It is added to the image and scrollbar areas.
- *
- * @param l the key listener
- * */
- public synchronized void addKeyListener(KeyListener l) {
- super.addKeyListener(l);
- imgDisplay.addKeyListener(l);
- hsbar.addKeyListener(l);
- vsbar.addKeyListener(l);
- }
-
- /**
- * Removes the specified key listener so that it no longer receives key
- * events from this component.
- *
- * @param l the key listener
- * */
- public synchronized void removeKeyListener(KeyListener l) {
- super.removeKeyListener(l);
- imgDisplay.removeKeyListener(l);
- hsbar.removeKeyListener(l);
- vsbar.removeKeyListener(l);
- }
-
- /**
- * Adds the specified mouse listener to receive mouse events from this
- * component. It is actually added to the image area only and not to the
- * scrollbar areas.
- *
- * @param l the mouse listener
- * */
- public synchronized void addMouseListener(MouseListener l) {
- super.addMouseListener(l);
- imgDisplay.addMouseListener(l);
- }
-
- /**
- * Removes the specified mouse listener so that it no longer receives
- * mouse events from this component.
- *
- * @param l the mouse listener
- * */
- public synchronized void removeMouseListener(MouseListener l) {
- super.removeMouseListener(l);
- imgDisplay.removeMouseListener(l);
- }
-
- /**
- * Adds the specified mouse motion listener to receive mouse motion events
- * from this component. It is actually added to the image area only and
- * not to the scrollbar areas.
- *
- * @param l the mouse motion listener
- * */
- public synchronized void addMouseMotionListener(MouseMotionListener l) {
- super.addMouseMotionListener(l);
- imgDisplay.addMouseMotionListener(l);
- }
-
- /**
- * Removes the specified mouse motion listener so that it no longer
- * receives mouse motion events from this component.
- *
- * @param l the mouse motion listener
- * */
- public synchronized void removeMouseMotionListener(MouseMotionListener l) {
- super.removeMouseMotionListener(l);
- imgDisplay.removeMouseMotionListener(l);
- }
- /**
- * Sets the background color of this component. It sets the background of
- * the 3 areas (image and scrollbars) plus the container itself.
- *
- * @param c The color to become background color for this component
- * */
- public synchronized void setBackground(Color c) {
- super.setBackground(c);
- imgDisplay.setBackground(c);
- hsbar.setBackground(c);
- vsbar.setBackground(c);
- }
-
- /**
- * Set the cursor image to a predefined cursor. It sets the cursor of the
- * image area and this container to the specified one. It does not set the
- * cursor of the scrollbars.
- *
- * @param cursor One of the constants defined by the Cursor class.
- * */
- public synchronized void setCursor(Cursor cursor) {
- super.setCursor(cursor);
- imgDisplay.setCursor(cursor);
- }
-
- /**
- * Enables or disables this component, depending on the value of the
- * parameter b. An enabled component can respond to user input and
- * generate events. Components are enabled initially by default.
- *
- * @param b If true, this component is enabled; otherwise this component
- * is disabled.
- * */
- public synchronized void setEnabled(boolean b) {
- super.setEnabled(b);
- imgDisplay.setEnabled(b);
- hsbar.setEnabled(b);
- vsbar.setEnabled(b);
- }
-
- /**
- * Sets the foreground color of this component. It sets the foreground of
- * the 3 areas (image display and scrollbars) plus this contaioner's
- * foreground.
- *
- * @param c The color to become this component's foreground color.
- * */
- public synchronized void setForeground(Color c) {
- super.setForeground(c);
- imgDisplay.setForeground(c);
- hsbar.setForeground(c);
- vsbar.setForeground(c);
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(String name,Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public Component add(Component comp, int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public void add(Component comp, Object constraints) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since no components can be added to
- * this container.
- * */
- public void add(Component comp, Object constraints, int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void remove(int index) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void remove(Component comp) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the components should never be
- * removed from this container.
- * */
- public void removeAll() {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the layout manager is
- * internally set and can not be changed.
- * */
- public void setLayout(LayoutManager mgr) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Sets the scrollbars values, according to the image display area and
- * image size. The current scroll position is kept.
- *
- * */
- private void setScrollbars() {
- Dimension asz; // actual image area size
- Dimension psz; // preferred size
- int pos; // current scroll position
- int szx,szy; // actual image display area size
-
- if (!imgDisplay.calcDim()) {
- // While the image dimensions are not known we can't really update
- // the scrollbar.
- return;
- }
-
- // Get the dimensions
- asz = imgDisplay.getSize();
- psz = imgDisplay.getPreferredSize();
-
- // Initialize lastZoom and lastSize if never done yet
- if (lastZoom == 0f) lastZoom = zoom;
- if (lastSize == null) lastSize = new Dimension(asz.width,asz.height);
-
- // Get the actual display size
- szx = (asz.width < psz.width) ? asz.width : psz.width;
- szy = (asz.height < psz.height) ? asz.height : psz.height;
-
- // Set horizontal scrollbar
- pos = (int)((hsbar.getValue()+lastSize.width/2f)/lastZoom*zoom-szx/2f);
- if (pos > (psz.width-asz.width)) pos = psz.width-asz.width;
- if (pos < 0) pos = 0;
- if (asz.width <= 0) asz.width = 1;
- if (psz.width <= 0) psz.width = 1;
- hsbar.setValues(pos,asz.width,0,psz.width);
- asz.width = (int)(asz.width*BLOCK_INCREMENT_PROPORTION);
- if (asz.width <= 0) asz.width = 1;
- hsbar.setBlockIncrementI(asz.width);
-
- // Set vertical scrollbar
- pos = (int)((vsbar.getValue()+lastSize.height/2f)/lastZoom*zoom-szy/2f);
- if (pos > (psz.height-asz.height)) pos = psz.height-asz.height;
- if (pos < 0) pos = 0;
- if (asz.height <= 0) asz.height = 1;
- if (psz.height <= 0) psz.height = 1;
- vsbar.setValues(pos,asz.height,0,psz.height);
- asz.height = (int)(asz.height*BLOCK_INCREMENT_PROPORTION);
- if (asz.height <= 0) asz.height = 1;
- vsbar.setBlockIncrementI(asz.height);
-
- // Save the zoom and display size used in the scrollbar calculation
- lastZoom = zoom;
- lastSize.width = szx;
- lastSize.height = szy;
- }
-
- /**
- * This class implements the component that displays the currently
- * viewable image portion inside the ImgScrollPane. It handles the
- * necessary erasing, zooming and panning.
- *
- * NOTE: extending 'Canvas' instead of 'Component' solves the
- * flickering problem of lightweight components which are in heavyweight
- * containers.
- *
- * */
- private class ImageScrollDisplay extends Canvas {
-
- /** The image to be displayed
- *
- * @serial */
- Image img;
-
- /** The preferred size for this component
- *
- * @serial */
- Dimension dim = new Dimension();
-
- /** If the current graphics context should be erased prior to drawing
- * the image. Set when the image and/or zoom factor is changed.
- *
- * @serial */
- boolean erase;
-
- /** The image dimensions, without any scaling. Set as soon as they are
- known.
- *
- * @serial */
- Dimension imgDim = new Dimension();
-
- /** The image dimension flags, as in ImageObserver. The
- * ImageObserver.WIDTH and ImageObserver.HEIGHT flags are set whenever
- * the dimension is stored in imgDim. They are reset whenever the
- * image changes.
- *
- * @serial */
- int dimFlags;
-
- /** The last offset used in update().
- *
- * @serial */
- Point lastUpdateOffset;
-
- /**
- * Sets the image to display in this component. If the image is not
- * ready for display it will be prepared in the current thread. The
- * current zoom factor applies.
- *
- * If the image is not ready for display (i.e. it has not been
- * rendered at its natural size) it will be rendered in the current
- * thread, if not being already rendered in another one. This means
- * that the current thread can block until the image is ready.
- *
- * If the image is rendered incrementally (it depends on the
- * underlying 'ImageProducer') it will be displayed in that way if the
- * incremental display is set for the Component class. See the
- * 'imageUpdate()' method of the 'Component' class.
- *
- * If the image is the same as the current one nothing is done.
- *
- * @param img The image to display.
- *
- * @see Component#imageUpdate
- *
- * */
- void setImage(Image img) {
- // Update object state
- synchronized (ImgScrollPane.this) {
- if (img == null) {
- throw new IllegalArgumentException();
- }
- // If same image do nothing
- if (this.img == img) {
- return;
- }
-
- // (Re)initialize
- dimFlags = 0;
- this.img = img;
- lastSize = null;
- lastZoom = 0f;
- setScrollbars();
- // Set to erase previous image
- erase = true;
- }
- // Start image production (if the image is already being prepared
- // the method does nothing)
- ImgScrollPane.this.prepareImage(img,this);
- }
-
- /**
- * Returns the minimum size for this component, which is (0,0).
- *
- * @return The minimum size
- *
- * */
- public Dimension getMinimumSize() {
- return new Dimension(0,0);
- }
-
- /**
- * Returns the maximum size for this component, which is infinite.
- *
- * @return The maximum size
- *
- * */
- public Dimension getMaximumSize() {
- return new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE);
- }
-
- /**
- * Returns the preferred size for this component, which is the image
- * display size, if known, the previous image display size, if any, or
- * the size specified at the constructor.
- *
- * @return The preferred size for this component.
- *
- * */
- public Dimension getPreferredSize() {
- return dim;
- }
-
- /**
- * Monitors the image rendering for dimensions and calls the
- * superclass' 'imageUpdate()' method. If the display size of the
- * image is not yet known and the image dimensions are obtained, then
- * the scrollbars' values are set. If 'img' is not the current image
- * to display nothing is done and 'false' is returned indicating that
- * nothing more is necessary for it.
- *
- * @see ImageObserver#imageUpdate
- *
- * @see Component#imageUpdate
- *
- * */
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int w, int h) {
- if (this.img != img) {
- // Not the image we want to display now (might be an old one)
- // => do nothing and no more info needed on that image
- return false;
- }
- // If got the image dimensions then store them and set component
- // size as appropriate.
- if ((infoflags & (ImageObserver.WIDTH|ImageObserver.HEIGHT)) != 0) {
- // Got some image dimension
- synchronized (ImgScrollPane.this) {
- // Read the dimensions received
- if ((infoflags & ImageObserver.WIDTH) != 0) {
- imgDim.width = w;
- dimFlags |= ImageObserver.WIDTH;
- }
- if ((infoflags & ImageObserver.HEIGHT) != 0) {
- imgDim.height = h;
- dimFlags |= ImageObserver.HEIGHT;
- }
- // If we got to know the image dimensions force the layout
- // to be done (to see if it is necessary to show
- // scrollbars)
- if (dimFlags ==
- (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- ImgScrollPane.this.doLayout();
- }
- }
- }
- // Call the superclass' method to continue processing
- return super.imageUpdate(img,infoflags,x,y,w,h);
- }
-
- /**
- * Paints the image, if any, on the graphics context by calling
- * update().
- *
- * @param g The graphics context to paint on.
- *
- * */
- public void paint(Graphics g) {
- // Now call update as usual
- update(g);
- }
-
- /**
- * Updates the component by drawing the relevant part of the image
- * that fits within the Graphics clipping area of 'g'. If the image is
- * not already being prepared for rendering or is not already rendered
- * this method does not start it. This is to avoid blocking the AWT
- * threads for rendering the image. The image rendering is started by
- * the 'setImage()' method.
- *
- * @param g The graphics context where to draw
- *
- * @see #setImage
- *
- * */
- public void update(Graphics g) {
- Image img; // The image to display
- float zoom; // The zoom factor
- boolean erase; // If the display area should be erased
- int dx1,dy1; // Scaling destionation upper-left corner
- int dx2,dy2; // Scaling destination down-right corner
- int sx1,sy1; // Scaling source upper-left corner
- int sx2,sy2; // Scaling source down-right corner
- int ox,oy; // Centering offset
- Rectangle b; // Bounds of the display area
- int offx,offy; // Offset of the upper-left corner
- int loffx,loffy; // Offset of the upper-left corner of last update
- boolean copyScroll;// If the scrolling should be done by copying
- Rectangle clip; // The clipping area
- int status; // The image fetching status
-
- // Copy to local variables in a synchronized block to avoid races
- synchronized (ImgScrollPane.this) {
- img = this.img;
- zoom = ImgScrollPane.this.zoom;
- erase = this.erase;
- copyScroll = ImgScrollPane.this.copyScroll;
- this.erase = false;
-
- // If no image or the image has not started preparation yet do
- // nothing. We do not want to start the image preparation in
- // this thread because it can be long.
- if (img == null || (status = this.checkImage(img,null)) == 0) {
- return;
- }
- // Get the display size and eventual centering offset for the
- // image.
- b = this.getBounds();
- ox = (b.width > dim.width) ? (b.width-dim.width)/2 : 0;
- oy = (b.height > dim.height) ? (b.height-dim.height)/2 : 0;
- // Get the display offset
- clip = g.getClipBounds();
- if (lastUpdateOffset != null &&
- (clip.width < b.width || clip.height < b.height)) {
- // The clip is smaller than the display area => we need to
- // paint with the last offset to avoid screwing up the
- // displayed image.
- offx = lastUpdateOffset.x;
- offy = lastUpdateOffset.y;
- }
- else {
- // The clipping area covers the whole display area => we
- // can use the current offset.
- offx = hsbar.getValue();
- offy = vsbar.getValue();
- }
- // Get and update the offset of last update
- if (lastUpdateOffset == null) {
- lastUpdateOffset = new Point();
- }
- loffx = lastUpdateOffset.x;
- loffy = lastUpdateOffset.y;
- lastUpdateOffset.x = offx;
- lastUpdateOffset.y = offy;
- // Set the display size according to zoom
- if (zoom == 1f) {
- // Natural image size, no scaling
- // Displace the origin of the image according to offset
- ox -= offx;
- oy -= offy;
- // No zoom so no translation for scaling compensation needed
- sx1 = sy1 = 0; // to keep compiler happy
- sx2 = sy2 = 0; // to keep compiler happy
- dx1 = dy1 = 0; // to keep compiler happy
- dx2 = dy2 = 0; // to keep compiler happy
- }
- else {
- int sox,soy; // Scaling compensation offset
- // Calculate coordinates of lower right corner for scaling
- if (dimFlags !=
- (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- // Image dims not yet available we can't display
- return;
- }
- sx1 = sy1 = 0;
- sx2 = imgDim.width;
- sy2 = imgDim.height;
- dx1 = dy1 = 0;
- dx2 = dim.width;
- dy2 = dim.height;
- sox = soy = 0;
- // Limit the scaling area according to display size so
- // that scaling operates only on the area to be displayed
- if (dx2 > b.width) {
- // Calculate coordinates of displayed portion
- dx2 = b.width+ ((zoom>1f) ? (int)Math.ceil(zoom) : 0);
- if ((int)zoom == zoom) {
- // For integer zoom make dx2 a multiple of zoom
- dx2 = (int)(Math.ceil(dx2/zoom)*zoom);
- }
- sx1 = (int)(offx/zoom);
- sx2 = sx1 + (int)(dx2/zoom);
- // Compensate the scaling on integer coordinates with
- // an offset
- sox = (int)(sx1*zoom-offx);
- }
- if (dy2 > b.height) {
- // Calculate coordinates of displayed portion
- dy2 = b.height + ((zoom>1f) ? (int)Math.ceil(zoom) : 0);
- if ((int)zoom == zoom) {
- // For integer zoom make dy2 a multiple of zoom
- dy2 = (int)(Math.ceil(dy2/zoom)*zoom);
- }
- sy1 = (int)(offy/zoom);
- sy2 = sy1 + (int)(dy2/zoom);
- // Compensate the scaling on integer coordinates with
- // an extra offset
- soy = (int)(sy1*zoom-offy);
- }
- // Apply centering offset and scaling compensation offset
- dx1 += ox + sox;
- dy1 += oy + soy;
- dx2 += ox + sox;
- dy2 += oy + soy;
- }
- }
- // If the image is not yet complete and we are scrolling set to
- // erase to avoid leftovers of previous scroll on parts of the
- // image which are not yet ready
- if ((status & ImageObserver.ALLBITS) == 0 &&
- (loffx != offx || loffy != offy)) {
- erase = true;
- }
- // Now we have the necessary info for display. We do it outside
- // synchronized to avoid any potential deadlocks with imageUpdate().
- if (erase) {
- // We need to erase the current image. Make sure that we
- // redraw everything by setting the clipping area to the whole
- // display one.
- g.setClip(0,0,b.width,b.height);
- g.setColor(this.getBackground());
- g.fillRect(0,0,b.width,b.height);
- }
-
- // Use copy scrolling if the image has not been erased, we are
- // scrolling, the image is complete, and copy scrolling is enabled.
- if (copyScroll && !erase && (loffx != offx || loffy != offy) &&
- (status & ImageObserver.ALLBITS) != 0) {
- // We might be able to move some part of the displayed area
- // instead of redrawing everything.
-
- // We are just trasnlating the current image, so we can reuse
- // a part of it.
-
- int culx,culy; // Clipping area upper-left corner (inclusive)
- int cdrx,cdry; // Clipping area down-right corner (exclusive)
- int vulx,vuly; // Valid area upper-left corner (inclusive)
- int vdrx,vdry; // Valid area down-right corner (exclusive)
-
- culx = clip.x;
- culy = clip.y;
- cdrx = clip.x+clip.width;
- cdry = clip.y+clip.height;
-
- // Initialize valid area as the current display area after the
- // translation.
- vulx = loffx-offx;
- vuly = loffy-offy;
- vdrx = vulx+b.width;
- vdry = vuly+b.height;
-
- // Make new valid area the intersection of the clipping area
- // and the valid area.
- if (culx > vulx) vulx = culx;
- if (culy > vuly) vuly = culy;
- if (cdrx < vdrx) vdrx = cdrx;
- if (cdry < vdry) vdry = cdry;
-
- // If the new valid area is non-empty then copy current image
- // data
- if (vulx < vdrx && vuly < vdry) {
- // Ok we can move a part instead of repainting
- g.copyArea(vulx+offx-loffx,vuly+offy-loffy,
- vdrx-vulx,vdry-vuly,
- loffx-offx,loffy-offy);
- // Now we need to redraw the other parts
- if (culx < vulx) { // Need to draw at left
- g.setClip(culx,culy,vulx-culx,cdry-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (vdrx < cdrx) { // Need to draw at right
- g.setClip(vdrx,culy,cdrx-vdrx,cdry-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (culy < vuly) { // Need to draw at top
- g.setClip(vulx,culy,vdrx-vulx,vuly-culy);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- if (vdry < cdry) { // Need to draw at bottom
- g.setClip(vulx,vdry,vdrx-vulx,cdry-vdry);
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
- this);
- }
- }
- }
- else {
- // New valid area is empty, we need to draw everything
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,this);
- }
- }
- }
- else {
- // We are not translating, so we can't copy
- if (zoom == 1f) { // No scaling
- g.drawImage(img,ox,oy,this);
- }
- else { // Draw the image using on the fly scaling
- g.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,this);
- }
- }
- }
-
- /**
- * Calculates the image display dimensions according to the zoom and
- * image size. The dimensions are stored in 'dim'.
- *
- * @return True if the dimensions could be calculated, false if not
- * (i.e. not enough info is available).
- *
- * */
- boolean calcDim() {
- // We need the image dimensions
- if (dimFlags != (ImageObserver.WIDTH|ImageObserver.HEIGHT)) {
- // Image dims not yet available we can't do anything
- return false;
- }
- // Calculate dims
- if (zoom == 1f) {
- // Natural image dimension
- dim.width = imgDim.width;
- dim.height = imgDim.height;
- }
- else {
- // Apply zoom
- dim.width = (int)(zoom*imgDim.width);
- dim.height = (int)(zoom*imgDim.height);
- }
- return true;
- }
- }
-
- /**
- * Scrollbars for the ImgScrollPane container. They are normal AWT
- * Scrollbars, but with a thickness of
- * ImgScrollPane.SCROLLBAR_THICKNESS. Also many of the set method of the
- * Adjustable interface are overriden and throw IllegalArgumentException
- * since they are not to be used externally.
- *
- * */
- class ISPScrollbar extends Scrollbar {
-
- /**
- * Constructs a new scroll bar with the specified orientation and
- * values.
- *
- * The orientation argument must take one of the two values
- * Scrollbar.HORIZONTAL, or Scrollbar.VERTICAL, indicating a
- * horizontal or vertical scroll bar, respectively.
- *
- * @param orientation indicates the orientation of the scroll bar
- *
- * @param value the initial value of the scroll bar.
- *
- * @param visible the size of the scroll bar's bubble, representing
- * the visible portion; the scroll bar uses this value when paging up
- * or down by a page.
- *
- * @param min the minimum value of the scroll bar.
- *
- * @param max the maximum value of the scroll bar.
- *
- * @param svt The scrollbar visible type
- **/
- ISPScrollbar(int orientation,
- int value, int visible, int min, int max) {
- super(orientation,value,visible,min,max);
- }
-
- /**
- * Returns the preferred size of the scrollbar. It is the same as the
- * preferred size of a normal scrollbar but with a thickness of
- * ImgScrollPane.SCROLLBAR_THICKNESS.
- *
- * @return The Scrollbar preferred size
- * */
- public Dimension getPreferredSize() {
- Dimension psz = super.getPreferredSize();
- if (getOrientation() == HORIZONTAL) {
- psz.height = ImgScrollPane.SCROLLBAR_THICKNESS;
- }
- else {
- psz.width = ImgScrollPane.SCROLLBAR_THICKNESS;
- }
- return psz;
- }
-
- /**
- * Throws an IllegalArgumentException since the minimum value should
- * never be set externally.
- * */
- public void setMinimum(int min) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the maximum value should
- * never be set externally.
- * */
- public void setMaximum(int max) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the visible amount should
- * never be set externally.
- * */
- public void setVisibleAmount(int v) {
- throw new IllegalArgumentException();
- }
-
- /**
- * Throws an IllegalArgumentException since the block increment should
- * never be set externally.
- * */
- public void setBlockIncrement(int b) {
- super.setBlockIncrement(b);
- }
-
- /**
- * Sets the block increment for this scroll bar.
- *
- * The block increment is the value that is added (subtracted) when
- * the user activates the block increment area of the scroll bar,
- * generally through a mouse or keyboard gesture that the scroll bar
- * receives as an adjustment event.
- *
- * This is a version to be used by The ImgScrollPane class only.
- *
- * @param v the amount by which to increment or decrement the scroll
- * bar's value.
- * */
- void setBlockIncrementI(int v) {
- super.setBlockIncrement(v);
- }
-
- /**
- * Sets the value of this scroll bar to the specified value.
- *
- * If the value supplied is less than the current minimum or
- * greater than the current maximum, then one of those values is
- * substituted, as appropriate.
- *
- * This is a version to be used by The ImgScrollPane class only.
- *
- * @param newValue he new value of the scroll bar.
- * */
- void setValueI(int newValue) {
- super.setValue(newValue);
- }
-
- /**
- * Sets the value of this scroll bar to the specified value and
- * requests a repaint of the image area.
- *
- * If the value supplied is less than the current minimum or
- * greater than the current maximum, then one of those values is
- * substituted, as appropriate.
- *
- * @param newValue he new value of the scroll bar.
- * */
- public void setValue(int newValue) {
- // Set the value and check if we need to repaint
- synchronized (ImgScrollPane.this) {
- super.setValue(newValue);
- newValue = getValue(); // get the actual value for check
- if (imgDisplay.lastUpdateOffset != null) {
- if (getOrientation() == HORIZONTAL) {
- if (imgDisplay.lastUpdateOffset.x == newValue) {
- return; // No change
- }
- }
- else {
- if (imgDisplay.lastUpdateOffset.y == newValue) {
- return; // No change
- }
- }
- }
- }
- // New value changes from last drawn => repaint
- imgDisplay.repaint();
- }
- }
-}
diff --git a/CSJ2K/jj2kencoder/disp/TitleUpdater.jsl b/CSJ2K/jj2kencoder/disp/TitleUpdater.jsl
deleted file mode 100644
index 2f1103e9..00000000
--- a/CSJ2K/jj2kencoder/disp/TitleUpdater.jsl
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * CVS identifier:
- *
- * $Id: TitleUpdater.java,v 1.8 2002/06/24 14:04:58 grosbois Exp $
- *
- * Class: TitleUpdater
- *
- * Description: Thread to update display window title
- *
- *
- *
- * COPYRIGHT:
- *
- * This software module was originally developed by Raphaël Grosbois and
- * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
- * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
- * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
- * Centre France S.A) in the course of development of the JPEG2000
- * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
- * software module is an implementation of a part of the JPEG 2000
- * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
- * Systems AB and Canon Research Centre France S.A (collectively JJ2000
- * Partners) agree not to assert against ISO/IEC and users of the JPEG
- * 2000 Standard (Users) any of their rights under the copyright, not
- * including other intellectual property rights, for this software module
- * with respect to the usage by ISO/IEC and Users of this software module
- * or modifications thereof for use in hardware or software products
- * claiming conformance to the JPEG 2000 Standard. Those intending to use
- * this software module in hardware or software products are advised that
- * their use may infringe existing patents. The original developers of
- * this software module, JJ2000 Partners and ISO/IEC assume no liability
- * for use of this software module or modifications thereof. No license
- * or right to this software module is granted for non JPEG 2000 Standard
- * conforming products. JJ2000 Partners have full right to use this
- * software module for his/her own purpose, assign or donate this
- * software module to any third party and to inhibit third parties from
- * using this software module for non JPEG 2000 Standard conforming
- * products. This copyright notice must be included in all copies or
- * derivative works of this software module.
- *
- * Copyright (c) 1999/2000 JJ2000 Partners.
- * */
-package jj2000.disp;
-
-import java.awt.*;
-
-/**
- * This class should run as an independent thread to update tha main
- * display window title with current image scroll position and
- * zoom.
- * */
-public class TitleUpdater implements Runnable {
-
- /** The update perion, in milliseconds: 100 */
- static final int UPDATE_T = 100;
-
- /** The ImgScrollPane where the image is displayed */
- ImgScrollPane isp;
-
- /** The frame which title to update */
- Frame win;
-
- /** The base of the title */
- String btitle;
-
- /** The thread exits when this is true */
- volatile public boolean done = false;
-
- /**
- * Instantiates the title updater. The title of 'win' will be
- * regularly updated with the current zoom and scroll point. The
- * current zoom and scroll point are added to the basic title
- * given by 'btitle'.
- *
- * @param isp Where the image is displayed
- *
- * @param win The window which title to update
- *
- * @param btitle The base of the title.
- * */
- public TitleUpdater(ImgScrollPane isp, Frame win, String btitle) {
- this.isp = isp;
- this.win = win;
- this.btitle = btitle;
- }
-
- /**
- * The method that executes this thread. The method periodically
- * updates the title, if necessary, and puts to sleep the thread
- * for 100 msec. This method never returns. If the sleep of the
- * thread is interrupted, the title will be updated earlier and
- * the cycle will continue.
- * */
- public void run() {
- // Periodically update the window title
- Point lsp,sp;
- float lzf,zf;
- lsp = isp.getScrollPosition();
- lzf = isp.getZoom();
- while (!done) {
- sp = isp.getScrollPosition();
- zf = isp.getZoom();
- // Update title only if necessary
- if (zf != lzf || !sp.equals(lsp)) {
- win.setTitle(btitle+
- " @ ("+(int)(sp.x/zf)+","+
- (int)(sp.y/zf)+") : "+isp.getZoom());
- }
- lsp = sp;
- lzf = zf;
- try {
- Thread.currentThread().sleep(UPDATE_T);
- }
- catch (InterruptedException e) {
- }
- }
- }
-}
diff --git a/CSJ2K/jj2kencoder/j2kencoder.vjsproj b/CSJ2K/jj2kencoder/j2kencoder.vjsproj
deleted file mode 100644
index 85b6b25f..00000000
--- a/CSJ2K/jj2kencoder/j2kencoder.vjsproj
+++ /dev/null
@@ -1,54 +0,0 @@
-
- *
- * <applet code="CSJ2K.j2k.decoder.SimpleAppletDecoder.class"
- * archive="jj2000-aplt.jar"
- * width="512" height="512">
- * <param name="i" value="tools.jp2">
- * <param name="res" value"3">
- * </applet>
- *
- * */
-public class SimpleAppletDecoder extends Applet implements Runnable {
-
- /** The parameter info, with all possible options. */
- private static String pinfo[][] = Decoder.getAllParameters();
-
- /** The decoder */
- private Decoder dec;
-
- /** The parameter list to give to the decoder */
- private ParameterList pl;
-
- /** The thread where the decoder is run */
- private Thread decThread;
-
- /** If the decoder thread has already been started */
- private boolean decStarted;
-
- /** Where the image is displayed */
- private ImgScrollPane isp;
-
- /**
- * Initializes the applet. It reads the parameters and creates the decoder
- * thread.
- * */
- public void init() {
- ParameterList defpl;
- String param;
- int i;
- URL input;
-
- // Get the dfault parameter values
- defpl = new ParameterList();
- for (i=pinfo.length-1; i>=0; i--) {
- if(pinfo[i][3]!=null)
- defpl.Set(pinfo[i][0], pinfo[i][3]); //defpl.put(pinfo[i][0], pinfo[i][3]);
- }
-
- // Get all parameters from and put them in a parameter list
- pl = new ParameterList(defpl);
- for (i=0; i
- * -
- * -
- * -
- * -
- * -
- * -
- * - 'Q' or 'q': exit the application
- * - '-': zoom out by 2
- * - '=' or '+': zoom in by 2
- * - '1': display at a zoom of 1
- * - 'Ctrl-C': exit the application
- *
- *
- *
- *
- *
- * -
- * -
- * -
- * -
- * -
- * -
- * - 'Q' or 'q': exit the application
- * - '-': zoom out by 2
- * - '=' or '+': zoom in by 2
- * - '1': display at a zoom of 1
- * - 'Ctrl-C': exit the application
- *
- *