Ejemplo n.º 1
0
		/**
		 * Set up the applet's GUI.
		 * As recommended, the init method executes this in the event-dispatching 
		 * thread.
		 */
		public void run()
		{
			Container pane = getContentPane();
			pane.setLayout(new BorderLayout());

			// Build the button controls
			JRadioButton voronoiButton = new JRadioButton("Voronoi Diagram");
			voronoiButton.setActionCommand("voronoi");
			JRadioButton delaunayButton = new JRadioButton("Delaunay Triangulation");
			delaunayButton.setActionCommand("delaunay");
			JButton clearButton = new JButton("Clear");
			clearButton.setActionCommand("clear");
			
			ButtonGroup group = new ButtonGroup();
			group.add(voronoiButton);
			group.add(delaunayButton);
			JPanel buttonPanel = new JPanel();
			buttonPanel.add(voronoiButton);
			buttonPanel.add(delaunayButton);
			buttonPanel.add(clearButton);
			pane.add(buttonPanel, "North");

			// Build the mouse-entry switches
			JLabel circleLabel = new JLabel("Show Empty Circles");
			circleLabel.setName("circles");
			JLabel delaunayLabel = new JLabel("Show Delaunay Edges");
			delaunayLabel.setName("delaunay");
			JLabel voronoiLabel = new JLabel("Show Voronoi Edges");
			voronoiLabel.setName("voronoi");
			JPanel switchPanel = new JPanel();
			switchPanel.add(circleLabel);
			switchPanel.add(new Label("     "));
			switchPanel.add(delaunayLabel);
			switchPanel.add(new Label("     "));
			switchPanel.add(voronoiLabel);
			pane.add(switchPanel, "South");

			// Build the graphics panel
			DelaunayPanel graphicsPanel = new DelaunayPanel();
			graphicsPanel.setBackground(Color.gray);
			pane.add(graphicsPanel, "Center");

			// Register the listeners
			voronoiButton.addActionListener(graphicsPanel);
			delaunayButton.addActionListener(graphicsPanel);
			clearButton.addActionListener(graphicsPanel);
			graphicsPanel.addMouseListener(graphicsPanel);
			circleLabel.addMouseListener(graphicsPanel);
			delaunayLabel.addMouseListener(graphicsPanel);
			voronoiLabel.addMouseListener(graphicsPanel);

			// Initialize the radio buttons
			voronoiButton.doClick();
		}
Ejemplo n.º 2
0
 internal override void setChoices([In] StringArray obj0)
 {
   if (this.groupPanel != null)
   {
     ((Container) this.panel).remove((Component) this.groupPanel);
     Iterator iterator = this.buttons.values().iterator();
     while (iterator.hasNext())
       this.group.remove((AbstractButton) iterator.next());
     this.buttons.clear();
   }
   this.groupPanel = new JPanel();
   ((JComponent) this.groupPanel).setOpaque(false);
   ((Container) this.groupPanel).setLayout((LayoutManager) new BoxLayout((Container) this.groupPanel, 1));
   this.group = new ButtonGroup();
   this.buttons = (Map) new HashMap();
   int num = 0;
   for (int i = 0; i < obj0.size(); ++i)
   {
     string str = obj0.get(i);
     num |= String.instancehelper_equals(str, (object) Chooser.access\u0024200(this.this\u00240)) ? 1 : 0;
     JRadioButton jradioButton = new JRadioButton(str);
     this.buttons.put((object) str, (object) jradioButton);
     this.group.add((AbstractButton) jradioButton);
     ((Container) this.groupPanel).add((Component) jradioButton);
     ((AbstractButton) jradioButton).setActionCommand(str);
     ((AbstractButton) jradioButton).addActionListener((ActionListener) this);
   }
   if (num == 0)
     Chooser.access\u0024202(this.this\u00240, (string) null);
   if (Chooser.access\u0024300(this.this\u00240) != null && Chooser.access\u0024400(this.this\u00240).containsKey("selected"))
     Chooser.access\u0024202(this.this\u00240, Chooser.access\u0024500(this.this\u00240).getString("selected"));
   if (Chooser.access\u0024600(this.this\u00240) != null && Chooser.access\u0024200(this.this\u00240) != null)
   {
     Chooser.access\u0024700(this.this\u00240).putString("selected", Chooser.access\u0024200(this.this\u00240));
     this.selected = (JRadioButton) this.buttons.get((object) Chooser.access\u0024200(this.this\u00240));
     ((AbstractButton) this.selected).setSelected(true);
   }
   else if (Chooser.access\u0024800(this.this\u00240) != null && Chooser.access\u0024900(this.this\u00240).containsKey("default"))
   {
     this.selected = (JRadioButton) this.buttons.get((object) Chooser.access\u00241000(this.this\u00240).getString("default"));
     ((AbstractButton) this.selected).setSelected(true);
   }
   else
     this.selected = (JRadioButton) null;
   ((JComponent) this.this\u00240).setEnabled(((Boolean) this.this\u00240.__\u003C\u003Eeditable.getValue()).booleanValue());
   ((Container) this.panel).add((Component) this.groupPanel);
   ((JComponent) this.this\u00240).revalidate();
   ((Component) this.this\u00240).repaint();
   ((Component) this.this\u00240).setSize(((JComponent) this.this\u00240).getPreferredSize());
 }