001/* An applet that uses Ptolemy II SDF domain. 002 003 Copyright (c) 1999-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 */ 027package ptolemy.domains.sdf.demo.HTVQ; 028 029import java.awt.BorderLayout; 030 031import javax.swing.JLabel; 032import javax.swing.JPanel; 033 034import ptolemy.actor.gui.AWTContainer; 035import ptolemy.actor.gui.MoMLApplet; 036import ptolemy.actor.lib.gui.SequencePlotter; 037import ptolemy.domains.sdf.lib.vq.ImageDisplay; 038import ptolemy.kernel.CompositeEntity; 039 040/////////////////////////////////////////////////////////////////// 041//// HTVQApplet 042 043/** 044 An applet that uses Ptolemy II SDF domain. 045 046 @author Steve Neuendorffer 047 @version $Id$ 048 @since Ptolemy II 0.3 049 @Pt.ProposedRating Red (eal) 050 @Pt.AcceptedRating Red (cxh) 051 */ 052@SuppressWarnings("serial") 053public class HTVQApplet extends MoMLApplet { 054 /////////////////////////////////////////////////////////////////// 055 //// public methods //// 056 057 /** Place the placeable objects in a customized panel. 058 */ 059 @Override 060 public void _createView() { 061 super._createView(); 062 063 JPanel displayPanel = new JPanel(); 064 displayPanel.setLayout(new BorderLayout()); 065 066 // So that the background color comes through... 067 displayPanel.setBackground(null); 068 069 JPanel originalPanel = new JPanel(); 070 JPanel compressedPanel = new JPanel(); 071 072 // JPanel prnPanel = new JPanel(); 073 074 // // So the background shows through. 075 // prnPanel.setBackground(null); 076 // prnPanel.setLayout(new BorderLayout()); 077 // prnPanel.add(new JLabel("SNR (dB)"), BorderLayout.NORTH); 078 // displayPanel.add(prnPanel, BorderLayout.SOUTH); 079 080 CompositeEntity toplevel = (CompositeEntity) _toplevel; 081 ImageDisplay consumer = (ImageDisplay) toplevel.getEntity("Compressed"); 082 compressedPanel.add(new JLabel("Compressed"), BorderLayout.NORTH); 083 consumer.place(compressedPanel); 084 displayPanel.add(compressedPanel, BorderLayout.EAST); 085 consumer.setBackground(null); 086 087 ImageDisplay original = (ImageDisplay) toplevel.getEntity("Original"); 088 originalPanel.add(new JLabel("Original"), BorderLayout.NORTH); 089 original.place(originalPanel); 090 displayPanel.add(originalPanel, BorderLayout.WEST); 091 original.setBackground(null); 092 093 SequencePlotter plot = (SequencePlotter) toplevel 094 .getEntity("Signal To Noise Ratio"); 095 096 JPanel plotPanel = new JPanel(); 097 plot.place(new AWTContainer(plotPanel)); 098 plotPanel.setBackground(null); 099 100 JPanel appletPanel = new JPanel(); 101 appletPanel.setLayout(new BorderLayout()); 102 appletPanel.setBackground(null); 103 appletPanel.add(displayPanel, BorderLayout.NORTH); 104 appletPanel.add(plotPanel, BorderLayout.SOUTH); 105 106 getContentPane().add(appletPanel, BorderLayout.NORTH); 107 108 // To control the position, we put this in its own panel. 109 // JPanel textPanel = new JPanel(); 110 // prnPanel.add(textPanel, BorderLayout.SOUTH); 111 // prn.place(textPanel); 112 // textPanel.setBackground(null); 113 } 114}