/* * [Pws.java] * * Summary: Living Love Pathways Amanuensis. * * Copyright: (c) 1998-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 1998-07-08 original. * 1.1 1998-11-10 name and address. * 1.2 1998-11-16 add shame. * 1.3 1998-12-14 use jar, check JVM version * 1.4 2001-03-14 add boss to list * 1.5 2002-10-11 add what is happening, new layout, more choices apropos to terrorism. * 1.6 2005-05-23 use standard imports. * 1.7 2005-08-04 about box, ANT build, Javadoc * 1.8 2006-03-06 reformat with IntelliJ, add Javadoc * 1.9 2008-01-01 add pad and icons * 2.0 2008-04-06 add build to title, tidy code, fix spelling errors. */ package com.mindprod.pws; import com.mindprod.common18.Build; import com.mindprod.common18.CMPAboutBox; import com.mindprod.common18.FontFactory; import com.mindprod.common18.Hybrid; import com.mindprod.common18.VersionCheck; import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Label; import java.awt.List; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; /** * Living Love Pathways Amanuensis. *

* This program is just smoke and mirrors. It generates advice purely randomly. It pays not attention to the various * input settings. The inputs are simply for people to clarify the problem in their own minds. * * @author Roedy Green, Canadian Mind Products * @version 2.0 2008-04-06 add build to title, tidy code, fix spelling errors. * @since 1998-07-08 */ public final class Pws extends Applet { /** * height of Applet box in pixels. Does not include surrounding frame. */ private static final int APPLET_HEIGHT = 720; /** * Width of Applet box in pixels. */ private static final int APPLET_WIDTH = 564; private static final int FIRST_COPYRIGHT_YEAR = 1998; /** * non/displaying copyright */ private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 1998-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; private static final String RELEASE_DATE = "2008-04-06"; private static final String TITLE_STRING = "Living Love Pathways Amanuensis"; private static final String VERSION_STRING = "2.0"; private static final Color BACKGROUND_FOR_ADVICE = new Color( 0xf6f6ff )/* pale blue */; private static final Color BACKGROUND_FOR_BODY = Build.BACKGROUND_FOR_BLENDING; private static final Color BACKGROUND_FOR_BUTTON = Color.white; private static final Color BACKGROUND_FOR_INSTRUCTIONS = Color.white; private static final Color BACKGROUND_FOR_LABEL = Build.BACKGROUND_FOR_BLENDING; private static final Color FOREGROUND_FOR_ADVICE = Color.red; /** * for titles */ private static final Color FOREGROUND_FOR_BUTTON = new Color( 0xdc143c ); // --Commented out by Inspection (06/04/08 3:53 PM):private static final Color BLUE = Color.blue; private static final Color FOREGROUND_FOR_INSTRUCTIONS = new Color( 0x008000 ); private static final Color FOREGROUND_FOR_LABEL = new Color( 0x0000b0 ); /** * for titles */ private static final Color FOREGROUND_FOR_TITLE = new Color( 0xdc143c ); /** * for for titles */ private static final Font FONT_FOR_BUTTON = FontFactory.build( "Dialog", Font.BOLD, 18 ); /** * for for titles */ private static final Font FONT_FOR_TITLE = FontFactory.build( "Dialog", Font.BOLD, 16 ); /** * for for title second line */ private static final Font FONT_FOR_TITLE2 = FontFactory.build( "Dialog", Font.PLAIN, 14 ); /** * about button */ private Button about; /** * Advise button */ private Button advise; /** * word "advice" */ private Label adviceLabel; /** * used to help align */ private Label dummy; /** * word emotion */ private Label emotionLabel; /** * title and version */ private Label title; /** * second title line for app */ private Label title2; /** * word what */ private Label whatLabel; /** * word when */ private Label whenLabel; /** * word where */ private Label whereLabel; /** * word who */ private Label whoLabel; /** * select emotion from a list */ private List emotion; /** * select when from list */ private List when; /** * select where from list */ private List where; /** * select who from list */ private List who; /** * pathway text on what to do */ private TextArea advice; /** * instructions on use */ private TextArea instructions; /** * what happened */ private TextArea what; /** * allocate all Components */ private void buildComponents() { title = new Label( TITLE_STRING + " " + VERSION_STRING, Label.LEFT ); title.setFont( FONT_FOR_TITLE ); title.setForeground( FOREGROUND_FOR_TITLE ); title2 = new Label( "released:" + RELEASE_DATE + " build:" + Build.BUILD_NUMBER ); title2.setFont( FONT_FOR_TITLE2 ); title2.setForeground( FOREGROUND_FOR_TITLE ); about = new Button( "about" ); about.setForeground( FOREGROUND_FOR_BUTTON ); about.setBackground( BACKGROUND_FOR_BUTTON ); about.setFont( FONT_FOR_BUTTON ); about.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { // open aboutbox frame new CMPAboutBox( TITLE_STRING, VERSION_STRING, "Pathways Amanuensis:", "Help with personal problems using the Ken Keyes 12 pathways.", "freeware", RELEASE_DATE, FIRST_COPYRIGHT_YEAR, "Roedy Green", "PWS", "1.6" ); } } ); whenLabel = new Label( "when?", Label.LEFT ); whenLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); whenLabel.setForeground( FOREGROUND_FOR_LABEL ); when = new List( 4 ); when.setMultipleMode( false ); emotionLabel = new Label( "emotions?", Label.RIGHT ); emotionLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); emotionLabel.setForeground( FOREGROUND_FOR_LABEL ); emotion = new List( 4 ); emotion.setMultipleMode( true ); dummy = new Label( "" ); whereLabel = new Label( "where?", Label.LEFT ); whereLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); whereLabel.setForeground( FOREGROUND_FOR_LABEL ); where = new List( 4 ); where.setMultipleMode( false ); whoLabel = new Label( "who?", Label.RIGHT ); whoLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); whoLabel.setForeground( FOREGROUND_FOR_LABEL ); who = new List( 4 ); who.setMultipleMode( true ); whatLabel = new Label( "what?", Label.CENTER ); whatLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); whatLabel.setForeground( FOREGROUND_FOR_LABEL ); what = new TextArea( "Tersely describe what happened/is " + "happening as objectively as possible, no " + "justifications or judgements, Sargeant Joe " + "Friday style, (e.g. Jim hung up the phone " + "without saying goodbye) here:", 4, 60, TextArea.SCROLLBARS_NONE ); what.setEditable( true ); what.setFont( FontFactory.build( "Dialog", Font.PLAIN, 16 ) ); what.setForeground( FOREGROUND_FOR_LABEL ); what.setBackground( BACKGROUND_FOR_LABEL ); adviceLabel = new Label( "advice", Label.CENTER ); adviceLabel.setFont( FontFactory.build( "Dialog", Font.BOLD, 15 ) ); adviceLabel.setForeground( FOREGROUND_FOR_LABEL ); adviceLabel.setBackground( BACKGROUND_FOR_LABEL ); advice = new TextArea( "Advice based on the Twelve Pathways " + "from Ken Keyes' Handbook to Higher Consciousness " + "ISBN 0-09600688-8-0.", 4, 60, TextArea.SCROLLBARS_NONE ); advice.setEditable( false ); advice.setFont( FontFactory.build( "Dialog", Font.PLAIN, 16 ) ); advice.setForeground( FOREGROUND_FOR_LABEL ); advice.setBackground( BACKGROUND_FOR_ADVICE ); // too long for a label instructions = new TextArea( "Think of a troubling event, and select " + "where, when, and who was involved; " + "describe what happened; " + "then click 'advise'.", 2, 50, TextArea.SCROLLBARS_NONE ); instructions.setBackground( BACKGROUND_FOR_INSTRUCTIONS ); instructions.setForeground( FOREGROUND_FOR_INSTRUCTIONS ); instructions.setFont( FontFactory.build( "Dialog", Font.PLAIN, 13 ) ); instructions.setEditable( false ); advise = new Button( "advise" ); advise.setBackground( BACKGROUND_FOR_BUTTON ); advise.setForeground( FOREGROUND_FOR_BUTTON ); advise.setFont( FONT_FOR_BUTTON ); // legal list of times for ( int i = 0; i < PwsText.times.length; i++ ) { when.add( PwsText.times[ i ] ); } when.select( 4 );// set to today. // add legal list of emotions for ( int i = 0; i < PwsText.emotions.length; i++ ) { emotion.add( PwsText.emotions[ i ] ); } // leave none selected // add legal list of people for ( int i = 0; i < PwsText.people.length; i++ ) { who.add( PwsText.people[ i ] ); } // leave none selected // add legal list of locations for ( int i = 0; i < PwsText.locations.length; i++ ) { where.add( PwsText.locations[ i ] ); } // leave none selected } /** * layout all components in a GridBag */ private void layoutComponents() { // Layout: view with split screen to see code too. // 0 ----------1------ 2 ---- // 0 --------title--about---- // 1 --------title2-about---- // 2 when?----x--- emotions? // 3 ---when---x ---emotions--- // 4 // 5 where?----x---- who? // 6 ---where---x ---who---- // 7 // 8 what? // 9 --------what--------- // 10 // 11 // 12 advice // 13 -----advice---------- // 14 // 15 // 16 instructions ---advise // 0 1 2 // x y w h wtx wty anchor fill T L B R padx pady this.add( title, new GridBagConstraints( 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( 10, 10, 5, 5 ), 0, 0 ) ); this.add( title2, new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( 5, 10, 5, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( about, new GridBagConstraints( 2, 0, 1, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets( 10, 5, 5, 10 ), 10, 2 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( whenLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets( 5, 10, 0, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( when, new GridBagConstraints( 0, 3, 1, 2, 40.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets( 5, 10, 5, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady // keeps when from growing too big this.add( dummy, new GridBagConstraints( 1, 3, 1, 1, 30.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets( 5, 5, 5, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( emotionLabel, new GridBagConstraints( 2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets( 5, 5, 0, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( emotion, new GridBagConstraints( 2, 3, 1, 2, 40.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets( 5, 5, 5, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( whereLabel, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets( 5, 10, 0, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( where, new GridBagConstraints( 0, 6, 1, 3, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 5, 10, 5, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( whoLabel, new GridBagConstraints( 2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets( 5, 5, 0, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( who, new GridBagConstraints( 2, 6, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 5, 5, 5, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( whatLabel, new GridBagConstraints( 0, 8, 3, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets( 5, 10, 0, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( what, new GridBagConstraints( 0, 9, 3, 3, 100.0, 40.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets( 5, 10, 5, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( adviceLabel, new GridBagConstraints( 0, 12, 3, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets( 5, 10, 0, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( advice, new GridBagConstraints( 0, 13, 3, 3, 100.0, 40.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets( 5, 10, 5, 10 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( instructions, new GridBagConstraints( 0, 16, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( 5, 10, 10, 5 ), 0, 0 ) ); // x y w h wtx wty anchor fill T L B R padx pady this.add( advise, new GridBagConstraints( 2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets( 5, 5, 10, 10 ), 0, 0 ) ); } /** * Allow this Applet to run as as application as well. * * @param args command line arguments ignored. */ public static void main( String args[] ) { Hybrid.fireup( new Pws(), TITLE_STRING + " " + VERSION_STRING, APPLET_WIDTH, APPLET_HEIGHT ); } // end main /** * Called by the browser or Applet viewer to inform * this Applet that it is being reclaimed and that it should destroy * any resources that it has allocated. */ public void destroy() { about = null; advice = null; adviceLabel = null; advise = null; dummy = null; emotion = null; emotionLabel = null; instructions = null; title2 = null; title = null; what = null; whatLabel = null; when = null; whenLabel = null; where = null; whereLabel = null; who = null; whoLabel = null; } /** * Called by the browser or Applet viewer to inform * this Applet that it has been loaded into the system. */ public void init() { if ( !VersionCheck.isJavaVersionOK( 1, 8, 0, this ) ) { return; } setBackground( BACKGROUND_FOR_BODY ); setLayout( new GridBagLayout() ); buildComponents(); layoutComponents(); // Register Listeners TheListener theListener = new TheListener(); advise.addActionListener( theListener ); this.validate(); this.setVisible( true ); } // end init /** * Inner class to act as listener to respond to all end-user actions. */ private final class TheListener implements ActionListener { /** * Notice any change to one of the list box selectors. * * @param event details of just what the user clicked. */ public void actionPerformed( ActionEvent event ) { final Object object = event.getSource(); if ( object == advise/* verb : the button */ ) { /* noun: the text */ advice.setForeground( FOREGROUND_FOR_ADVICE ); advice.setText( PwsText.getRandomPathway() ); } } // end actionPerformed } // end TheListener } /** * PwsText specific texts for the application. */ final class PwsText { /** * possible emotions you might have felt full list of emotions, too long for a list box see * http://mindprod.com/livinglove/methods/lgloss.html#EMOTIONS */ static final String[] emotions = { "despair", "sadness", "grief", "fear", "worry", "dread", "embarrassment", "guilt", "loneliness", "boredom", "jealousy", "shame", "frustration", "disgust", "disdain", "hate", "resentment", "anger", "rage" }; /** * possible places you may have been upset */ static final String[] locations = { "office", "car", "street", "bus", "store", "court", "outdoors", "head", "body", "home", "town", "country", "planet", "solar system", "galaxy", "universe", "other" }; /** * possible people you may have been upset with */ static final String[] people = { "you", "spouse", "lover", "mother", "father", "son", "daughter", "relative", "neighbour", "friend", "teacher", "boss", "official", "famous person", "stranger", "country", "terrorist", "criminal", "street person", "victim", "emailer", "spammer", "netizen", "person on TV", "politician", "other" }; /** * possible times could have felt upset */ static final String[] times = { "more than a year ago", "more than a month ago", "more than a day ago", "yesterday", "today", "now", "tomorrow", "more that a day in the future", "more than a month in the future", "more than a year in the future" }; /** * the 12 pathways */ private static final String[] thePathways = { "I am freeing myself from security, sensation, and power addictions that make me try to forcefully " + "control situations in my life, and thus destroy my serenity and keeps me from loving myself and others.", "I am discovering how my consciousness dominating addictions create my illusory version of the changing " + "world of people and situations around me.", "I welcome the opportunity (even if painful) that my minute to minute experience offers me to become " + "aware of the addictions I must reprogram to be liberated from my robot-like emotional patterns.", "I always remember that I have everything I need to enjoy my here and now -- unless I am letting my " + "consciousness be dominated by demands and expectations based on the dead past or the imagined future.", "I take full responsibility here and now for everything I experience, for it is my own programming that " + "creates my actions and also influences the reactions of people around me.", "I accept myself completely here and now and consciously experience everything I feel, think, say, " + "and do (including my emotion backed addictions) as a necessary part of my growth into higher " + "consciousness.", "I open myself genuinely to all people by being willing to fully communicate my deepest feelings, " + "since hiding in any degree keep me stuck in my illusion of separateness from other people.", "I feel with loving compassion the problems of others without getting caught up emotionally in their " + "predicaments that are offering them messages they need for their growth.", "I act freely when I am tuned in, centred, and loving, but if possible, " + "I avoid acting when I am emotionally upset and depriving myself of the wisdom that flows from love and " + "expanded consciousness.", "I am continually calming the restless scanning of my rational mind in order to perceive the finer " + "energies that enable me to unitively merge with everything around me.", "I am constantly aware of which of the Seven Centres of Consciousness I am using, and I feel my energy, " + "perceptiveness, love and inner peace growing as I open all of the centres of consciousness.", "I am perceiving everyone, including myself, as an awakening being who is here to claim his or her " + "birthright to the higher consciousness planes of unconditional love and oneness." }; /** * smoke and mirrors, pathway is selected randomly. */ private static final Random wheel = new Random(); /** * use to avoid giving same random number twice in a row */ private static int prevPw = -1; /** * PwsText a randomly selected pathway * * @return text of one pathway */ static String getRandomPathway() { // select a pathway 0..11 int thisPw; // avoid consecutive dups do { // old style before nextInt( 12 ) in 1,2 thisPw = ( wheel.nextInt() & Integer.MAX_VALUE ) % 12; } while ( thisPw == prevPw ); prevPw = thisPw; return thePathways[ thisPw ]; } }