/** * File: TrigramDisplay.java * @author A.Kurd * * Description: Implements a Java 1.1 version of a GUI tool for displaying Trigram data collected in TrigramCount.java. * Credits: This program is modelled after the frequency test of the CryptoToolJ program by Ralph Morelli. * * Copyright: This program is in the public domain. You can do whatever you want with * it as long as I get credit for my work and as long as you offer your changes to me * so I can possible add them to the "official" version. */ package analyzers; // Analyzer plugins belong to this package import hcrypto.analyzer.*; // This is where Analyzer is import java.awt.TextArea; import hcrypto.cipher.*; import java.awt.*; import java.awt.event.*; public class TrigramDisplay extends Frame implements WindowListener, Analyzer{ public Frame frame; public TrigramCount tc= new TrigramCount(); //instance of the TrigramCount public String output = ""; //used to display things in the TextArea public TextArea display; public TextArea text; public static void TrigramDisplay(String text){ }//TrigramDisplay /*Necessary for the Analyzer package*/ public void setup(TextArea text, TextArea display) { this.text = text; this.display = display; } /*First method called for this class*/ public void run() { display.append("Trigram Display Called" + "\n"); //tells user they've called this class to display Trigram Data tc.count(text.getText()); //calculates Trigram frequency from TrigramCount frame(); //displays the data } /*This is the method to display the information collected in the string output. It outputs the top 15 trigrams in 5 rows of 3 columns.*/ public void frame(){ frame = new Frame ("Trigram"); frame.addWindowListener(this); frame.setResizable(true); frame.setSize(300, 200); frame.setLocation(5, 10); frame.setVisible(true); for (int k=0; k <15; k++){ if (k%3 == 0) output = output + "" + "\n"; if (tc.frequencies [k] [0] > 0) output = output + "\t "+ (tc.acc [k] + "-" + (char)tc.frequencies [k] [0] + "" + (char)tc.frequencies [k] [1] + "" + (char)tc.frequencies [k] [2] + "" + " ");}//for display = new TextArea (output); frame.add(display); frame.show(); }//frame public void windowClosing(WindowEvent e) { frame.dispose(); } public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} }//BigramDisplay Class