import java.awt.*;
import java.io.*;
/**
* A class which contains displays and controls related to the currently
* computed fundamental domain and the maxpow to use.
*
* @author Jonathan A. Poritz
* @version 1.7, 10 Sep 1998
*/
public class OutputPanel extends Panel {
/**
* A panel that contains the fundamental domain display's zoom in, zoom out,
* and reset buttons.
*/
Panel boundarybuttongroup;
/**
* Clicking this button resets to default the visible portion of the boundary
* of hyperbolic space for fundamental domain display.
*/
Button boundaryreset;
/**
* Clicking this button zooms in by a factor of two on the fundamental
* domain display.
*/
Button boundaryzoomin;
/**
* Clicking this button zooms out by a factor of two on the fundamental
* domain display.
*/
Button boundaryzoomout;
/**
* A panel for the display of fundamental domains on the boundary of
* hyperbolic space.
*/
BoundaryPanel boundarypanel;
/**
* A label declaring the portion of the boundary of hyperbolic space which
* is currently visible.
*/
Label boundarypanellabel;
/**
* A label showing the value of the currently computed maxpow.
*/
Label maxpowlabel;
/**
* A choice for the format of the fundamental domain display. Indices mean:
*
- 0
*
- use filled disks covering the interiors of isometric or equidistant
* hemispheres
*
- 1
*
- use circles indicating the boundaries of isometric or equidistant
* hemispheres
*
- 2
*
- use circles as above, each labelled by their index
*/
Choice diskorcircle;
/**
* A choice between using the currently computed maxpow or one of a number of
* preset alternatives. Possibilities are:
* - 0
*
- use the computed maxpow
*
- 1 - 10
*
- use this value as the maxpow
*
- 11
*
- maxpow=20
*
- 12
*
- maxpow=50
*
- 13
*
- maxpow=100
*
- 14
*
- maxpow=200
*/
Choice maxpowchoice;
/**
* A choice between computing Ford and Dirichlet fundamental domains.
* Indices mean:
*
*/
Choice fordordirichlet;
/**
* An object for laying out panels with the GrigBag layout manager.
*/
GridBagLayout gridbag;
/**
* A constraint object for the GrigBag laying out of panels.
*/
GridBagConstraints constraints;
/**
* An insets object for the GridBag laying out of panels.
*/
Insets insets;
/**
* A reference to the applet's inputpanel.
*
* @see FDBApplet#outputpanel
*/
InputPanel inputpanel;
/**
* Constructor for OutputPanels.
*/
public OutputPanel() {
// create objects for GridBag laying out
gridbag = new GridBagLayout();
constraints = new GridBagConstraints();
insets = new Insets(0,0,0,0);
// construct and lay out objects of boundarybuttongroup
boundarybuttongroup = new Panel();
boundaryreset = new Button("Reset");
boundaryzoomin = new Button("+");
boundaryzoomout = new Button("-");
boundarybuttongroup.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
boundarybuttongroup.add(boundaryreset);
boundarybuttongroup.add(boundaryzoomin);
boundarybuttongroup.add(boundaryzoomout);
// construct and lay out remaining pieces of outputpanel
boundarypanellabel = new Label();
boundarypanellabel.setAlignment(Label.CENTER);
maxpowchoice = new Choice();
maxpowchoice.addItem("... and use it");
maxpowchoice.addItem("... but use 1");
maxpowchoice.addItem("... but use 2");
maxpowchoice.addItem("... but use 3");
maxpowchoice.addItem("... but use 4");
maxpowchoice.addItem("... but use 5");
maxpowchoice.addItem("... but use 6");
maxpowchoice.addItem("... but use 7");
maxpowchoice.addItem("... but use 8");
maxpowchoice.addItem("... but use 9");
maxpowchoice.addItem("... but use 10");
maxpowchoice.addItem("... but use 20");
maxpowchoice.addItem("... but use 50");
maxpowchoice.addItem("... but use 100");
maxpowchoice.addItem("... but use 200");
maxpowlabel = new Label();
maxpowlabel.setAlignment(Label.RIGHT);
fordordirichlet = new Choice();
fordordirichlet.addItem("Ford");
fordordirichlet.addItem("Dirichlet");
fordordirichlet.select(1);
diskorcircle = new Choice();
diskorcircle.addItem("Disks");
diskorcircle.addItem("Circles");
diskorcircle.addItem("Circles w/ indices");
diskorcircle.select(2);
boundarypanel = new BoundaryPanel(boundarypanellabel, diskorcircle, fordordirichlet);
setLayout(gridbag);
constraints.gridwidth = 2;
constraints.gridheight = 1;
constraints.gridx = 0;
constraints.gridy = 0;
insets.top = 5;
insets.bottom = 5;
constraints.insets = insets;
gridbag.setConstraints(boundarybuttongroup, constraints);
add(boundarybuttongroup);
insets.top = 0;
constraints.gridy = 1;
gridbag.setConstraints(boundarypanel, constraints);
add(boundarypanel);
constraints.gridy = 2;
constraints.fill = GridBagConstraints.HORIZONTAL;
gridbag.setConstraints(boundarypanellabel, constraints);
add(boundarypanellabel);
constraints.gridy = 3;
constraints.anchor = GridBagConstraints.EAST;
constraints.gridwidth = 1;
gridbag.setConstraints(maxpowlabel, constraints);
add(maxpowlabel);
constraints.gridx = 1;
constraints.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(maxpowchoice, constraints);
add(maxpowchoice);
constraints.gridy = 4;
constraints.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(diskorcircle, constraints);
add(diskorcircle);
constraints.gridx = 0;
constraints.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(fordordirichlet, constraints);
add(fordordirichlet);
}
/**
* Java 1.0 event handling for the outputpanel.
*
* @param e the event to be handled.
*/
public boolean handleEvent(Event e) {
if (e.id != Event.ACTION_EVENT)
return false;
if (e.target == boundaryreset) {
boundarypanel.reset();
boundarypanellabel.setText(boundarypanel.toString());
return true;
}
else if (e.target == boundaryzoomin) {
boundarypanel.zoom(.5D);
return true;
}
else if (e.target == boundaryzoomout) {
boundarypanel.zoom(2D);
return true;
}
else if (e.target == diskorcircle) {
boundarypanel.repaint();
return true;
}
else if (e.target == fordordirichlet) {
// if we change from Ford or Dirichlet or vice versa, we will have
// to add or remove the distlinepanel
inputpanel.removeAll();
int index = fordordirichlet.getSelectedIndex();
if (index == 1) {
// Dirichlet, better reset the axis distance if it zero and the
// trace is elliptic or parabolic
if ((inputpanel.dist == 0D) && (inputpanel.trace.y == 0D) && (Math.abs(inputpanel.trace.x) < 2D))
inputpanel.dist = 1D;
inputpanel.add(inputpanel.distlinegroup);
}
inputpanel.add(inputpanel.traceplanegroup);
inputpanel.traceplanepanel.decomposed = false;
inputpanel.traceplanepanel.draw_axes = true;
inputpanel.update();
return true;
}
else if (e.target == maxpowchoice) {
int index = maxpowchoice.getSelectedIndex();
if (index == 0) {
boundarypanel.usecalcmaxpow = true;
boundarypanel.chosenmaxpow = 0;
}
else if (index < 11) {
boundarypanel.usecalcmaxpow = false;
boundarypanel.chosenmaxpow = index;
}
else {
switch(index) {
case 11:
boundarypanel.chosenmaxpow = 20;
break;
case 12:
boundarypanel.chosenmaxpow = 50;
break;
case 13:
boundarypanel.chosenmaxpow = 100;
break;
case 14:
boundarypanel.chosenmaxpow = 200;
break;
default:
return false;
}
boundarypanel.usecalcmaxpow = false;
}
boundarypanel.update();
return true;
}
return false;
}
}