001/*
002 * Copyright (c) 2004-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: welker $'
006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 
007 * '$Revision: 24234 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.gis.display;
031
032import ptolemy.actor.TypedAtomicActor;
033import ptolemy.actor.TypedIOPort;
034import ptolemy.data.StringToken;
035import ptolemy.data.type.BaseType;
036import ptolemy.kernel.CompositeEntity;
037import ptolemy.kernel.util.IllegalActionException;
038import ptolemy.kernel.util.NameDuplicationException;
039
040/**
041 * Name: ENMPCPVisualizer.java Purpose:The actor serves as a proxy to invoke a
042 * PCP plot window to display GARP presampling results. Knwon problem: c.f.
043 * ENMPCPFrame.java Author: Jianting Zhang Date: August, 2005
044 */
045public class ENMPCPVisualizer extends TypedAtomicActor {
046        // input ports
047        /** Description of the Field */
048        public TypedIOPort SampleStringPort = new TypedIOPort(this,
049                        "SampleStringPort", true, false);
050
051        /**
052         * Constructor for the ENMPCPVisualizer object
053         * 
054         *@param container
055         *            Description of the Parameter
056         *@param name
057         *            Description of the Parameter
058         *@exception NameDuplicationException
059         *                Description of the Exception
060         *@exception IllegalActionException
061         *                Description of the Exception
062         */
063        public ENMPCPVisualizer(CompositeEntity container, String name)
064                        throws NameDuplicationException, IllegalActionException {
065
066                super(container, name);
067                SampleStringPort.setTypeEquals(BaseType.STRING);
068
069                _attachText(
070                                "_iconDescription",
071                                "<svg>\n"
072                                                + "<rect x=\"-20\" y=\"-15\" "
073                                                + "width=\"40\" height=\"30\" "
074                                                + "style=\"fill:lightGrey\"/>\n"
075                                                + "<rect x=\"-15\" y=\"-10\" "
076                                                + "width=\"30\" height=\"20\" "
077                                                + "style=\"fill:white\"/>\n"
078                                                + "<line x1=\"-13\" y1=\"-6\" x2=\"-4\" y2=\"-6\" "
079                                                + "style=\"stroke:grey\"/>\n"
080                                                + "<line x1=\"-13\" y1=\"-2\" x2=\"0\" y2=\"-2\" "
081                                                + "style=\"stroke:grey\"/>\n"
082                                                + "<line x1=\"-13\" y1=\"2\" x2=\"-8\" y2=\"2\" "
083                                                + "style=\"stroke:grey\"/>\n"
084                                                + "<line x1=\"-13\" y1=\"6\" x2=\"4\" y2=\"6\" "
085                                                + "style=\"stroke:grey\"/>\n"
086                                                + "<text x=\"-10\" y=\"-10\" font-size=\"10\" fill=\"blue\">ENMPCP</text>"
087                                                + "</svg>\n");
088        }
089
090        /**
091         *@exception IllegalActionException
092         *                Description of the Exception
093         */
094        public void initialize() throws IllegalActionException {
095        }
096
097        /**
098         *@return Description of the Return Value
099         *@exception IllegalActionException
100         *                Description of the Exception
101         */
102        public boolean prefire() throws IllegalActionException {
103                return super.prefire();
104        }
105
106        /**
107         *@exception IllegalActionException
108         *                Description of the Exception
109         */
110        public void fire() throws IllegalActionException {
111                // System.out.println("firing ENMPCPVisualizer");
112                super.fire();
113
114                StringToken XMLStringToken = (StringToken) SampleStringPort.get(0);
115                String XMLString = XMLStringToken.stringValue();
116                System.out.println(XMLString);
117                try {
118                        ENMPCPFrame frame = new ENMPCPFrame(this.getName());
119                        frame.setVisible(true);
120                        frame.setData(XMLString);
121                } catch (Exception e) {
122                        e.printStackTrace();
123                }
124        }
125
126        /**
127         * The main program for the ENMPCPVisualizer class
128         * 
129         *@param args
130         *            The command line arguments
131         *@exception Exception
132         *                Description of the Exception
133         */
134        public static void main(String[] args) throws Exception {
135                ENMPCPVisualizer d = new ENMPCPVisualizer(null, "");
136                d.fire();
137        }
138}