FileDocCategorySizeDatePackage
Transform.javaAPI DocExample10010Tue Dec 12 19:00:00 GMT 2000None

Transform

public class Transform extends JApplet implements ActionListener, ItemListener

Fields Summary
JLabel
primLabel
JLabel
lineLabel
JLabel
paintLabel
JLabel
transLabel
JLabel
strokeLabel
TransPanel
display
static JComboBox
primitive
static JComboBox
line
static JComboBox
paint
static JComboBox
trans
static JComboBox
stroke
JButton
redraw
public static boolean
no2D
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        display.setTrans(trans.getSelectedIndex());
        display.renderShape();
   
public voidinit()


       
        GridBagLayout layOut = new GridBagLayout();
        getContentPane().setLayout(layOut);
        GridBagConstraints c = new GridBagConstraints();

        c.weightx = 1.0;
        c.fill = GridBagConstraints.BOTH;
        primLabel = new JLabel();
        primLabel.setText("Primitive");
        Font newFont = getFont().deriveFont(1);
        primLabel.setFont(newFont);
        primLabel.setHorizontalAlignment(JLabel.CENTER);
        layOut.setConstraints(primLabel, c);
        getContentPane().add(primLabel);

        lineLabel = new JLabel();
        lineLabel.setText("Lines");
        lineLabel.setFont(newFont);
        lineLabel.setHorizontalAlignment(JLabel.CENTER);
        layOut.setConstraints(lineLabel, c);
        getContentPane().add(lineLabel);

        paintLabel = new JLabel();
        paintLabel.setText("Paints");
        paintLabel.setFont(newFont);
        paintLabel.setHorizontalAlignment(JLabel.CENTER);
        layOut.setConstraints(paintLabel, c);
        getContentPane().add(paintLabel);

        c.gridwidth = GridBagConstraints.RELATIVE;
        transLabel = new JLabel();  
        transLabel.setText("Transforms");
        transLabel.setFont(newFont);
        transLabel.setHorizontalAlignment(JLabel.CENTER);
        layOut.setConstraints(transLabel, c);
        getContentPane().add(transLabel);

        c.gridwidth = GridBagConstraints.REMAINDER;
        strokeLabel = new JLabel();
        strokeLabel.setText("Rendering");
        strokeLabel.setFont(newFont);
        strokeLabel.setHorizontalAlignment(JLabel.CENTER); 
        layOut.setConstraints(strokeLabel, c);
        getContentPane().add(strokeLabel);

        GridBagConstraints ls = new GridBagConstraints();
        ls.weightx = 1.0;
        ls.fill = GridBagConstraints.BOTH;
        primitive = new JComboBox( new Object []{
                                   "rectangle",
                                   "ellipse",
                                   "text"});
        primitive.addItemListener(this);
        newFont = newFont.deriveFont(0, 14.0f);
        primitive.setFont(newFont);
        layOut.setConstraints(primitive, ls);
        getContentPane().add(primitive);

        line = new JComboBox( new Object []{  
                              "thin",
                              "thick",
                              "dashed"});
        line.addItemListener(this);
        line.setFont(newFont);
        layOut.setConstraints(line, ls);
        getContentPane().add(line);

        paint = new JComboBox( new Object[]{
                               "solid",
                               "gradient",
                               "polka"});
        paint.addItemListener(this);
        paint.setFont(newFont);
        layOut.setConstraints(paint, ls);
        getContentPane().add(paint);

        ls.gridwidth = GridBagConstraints.RELATIVE;

        trans = new JComboBox( new Object[]{
				"Identity",
				"rotate",
				"scale",
				"shear"});
	trans.addItemListener(this);
	trans.setFont(newFont);
	layOut.setConstraints(trans, ls);
	getContentPane().add(trans);

        ls.gridwidth = GridBagConstraints.REMAINDER;
        stroke = new JComboBox( new Object[]{
                                "Stroke",
                                "Fill",
                                "Stroke & Fill"}); 
        stroke.addItemListener(this);
        stroke.setFont(newFont);
        layOut.setConstraints(stroke, ls);
        getContentPane().add(stroke);

	GridBagConstraints button = new GridBagConstraints();
	button.gridwidth = GridBagConstraints.REMAINDER;
	redraw = new JButton("Redraw");
	redraw.addActionListener(this);
        redraw.setFont(newFont);
        layOut.setConstraints(redraw, button);
        getContentPane().add(redraw);

        GridBagConstraints tP = new GridBagConstraints();
        tP.fill = GridBagConstraints.BOTH;
        tP.weightx = 1.0;
        tP.weighty = 1.0;
        tP.gridwidth = GridBagConstraints.REMAINDER;
        display = new TransPanel();
        layOut.setConstraints(display, tP);
        display.setBackground(Color.white);
        getContentPane().add(display);

        validate();

    
public voiditemStateChanged(java.awt.event.ItemEvent e)

public static voidmain(java.lang.String[] argv)

        if ( argv.length > 0 && argv[0].equals( "-no2d" ) ) {
            Transform.no2D = true;
        }
        
        JFrame frame = new JFrame( "Transform" );
        frame.addWindowListener( new WindowAdapter(){
            public void windowClosing( WindowEvent e ){
                System.exit( 0 );
            }
        });                     

        JApplet applet = new Transform();
        frame.getContentPane().add( BorderLayout.CENTER, applet );
        
        applet.init();
        
        frame.setSize( 550, 400 );
        frame.show();