< prev index next >

src/demo/share/jfc/J2Ddemo/java2d/Tools.java

Print this page




  77  * start & stop on animated demos; control for cloning the demo; control for
  78  * printing the demo.  Expand and collapse the Tools panel with ToggleIcon.
  79  */
  80 @SuppressWarnings("serial")
  81 public final class Tools extends JPanel implements ActionListener,
  82         ChangeListener, Runnable {
  83     private final DemoInstVarsAccessor demoInstVars;
  84     private ImageIcon stopIcon, startIcon;
  85     private Font font = new Font(Font.SERIF, Font.PLAIN, 10);
  86     private Color roColor = new Color(187, 213, 238);
  87     private Surface surface;
  88     private Thread thread;
  89     private JPanel toolbarPanel;
  90     private JPanel sliderPanel;
  91     private JLabel label;
  92     private ToggleIcon bumpyIcon, rolloverIcon;
  93     private DecimalFormat decimalFormat = new DecimalFormat("000");
  94     protected boolean focus;
  95     public JToggleButton toggleB;
  96     public JButton printB;
  97     public JComboBox screenCombo;
  98     public JToggleButton renderB, aliasB;
  99     public JToggleButton textureB, compositeB;
 100     public JButton startStopB;
 101     public JButton cloneB;
 102     public boolean issueRepaint = true;
 103     public JToolBar toolbar;
 104     public JSlider slider;
 105     public boolean doSlider;
 106     public boolean isExpanded;
 107 
 108     @SuppressWarnings("LeakingThisInConstructor")
 109     public Tools(Surface surface, DemoInstVarsAccessor demoInstVars) {
 110         this.surface = surface;
 111         this.demoInstVars = demoInstVars;
 112 
 113         setLayout(new BorderLayout());
 114 
 115         stopIcon = new ImageIcon(DemoImages.getImage("stop.gif", this));
 116         startIcon = new ImageIcon(DemoImages.getImage("start.gif", this));
 117         bumpyIcon = new ToggleIcon(this, LIGHT_GRAY);


 150 
 151         s = surface.Rendering == RenderingHints.VALUE_RENDER_SPEED
 152                 ? "Speed" : "Quality";
 153         renderB = addTool("R", "Rendering " + s, this);
 154 
 155         s = surface.texture != null ? "On" : "Off";
 156         textureB = addTool("T", "Texture " + s, this);
 157 
 158         s = surface.composite != null ? "On" : "Off";
 159         compositeB = addTool("C", "Composite " + s, this);
 160 
 161         Image printBImg = DemoImages.getImage("print.gif", this);
 162         printB = addTool(printBImg, "Print the Surface", this);
 163 
 164         if (surface instanceof AnimatingSurface) {
 165             Image stopImg = DemoImages.getImage("stop.gif", this);
 166             startStopB = addTool(stopImg, "Stop Animation", this);
 167             toolbar.setPreferredSize(new Dimension(6*25, 26));
 168         }
 169 
 170         screenCombo = new JComboBox();
 171         screenCombo.setPreferredSize(new Dimension(100, 18));
 172         screenCombo.setFont(font);
 173         for (String name : GlobalControls.screenNames) {
 174             screenCombo.addItem(name);
 175         }
 176         screenCombo.addActionListener(this);
 177         toolbarPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
 178         toolbarPanel.setLocation(0, 6);
 179         toolbarPanel.setVisible(false);
 180         toolbarPanel.add(toolbar);
 181         toolbarPanel.add(screenCombo);
 182         toolbarPanel.setBorder(new EtchedBorder());
 183         add(toolbarPanel);
 184 
 185         setPreferredSize(new Dimension(200, 8));
 186 
 187         if (surface instanceof AnimatingSurface) {
 188             sliderPanel = new JPanel(new BorderLayout());
 189             label = new JLabel(" Sleep = 030 ms");
 190             label.setForeground(BLACK);




  77  * start & stop on animated demos; control for cloning the demo; control for
  78  * printing the demo.  Expand and collapse the Tools panel with ToggleIcon.
  79  */
  80 @SuppressWarnings("serial")
  81 public final class Tools extends JPanel implements ActionListener,
  82         ChangeListener, Runnable {
  83     private final DemoInstVarsAccessor demoInstVars;
  84     private ImageIcon stopIcon, startIcon;
  85     private Font font = new Font(Font.SERIF, Font.PLAIN, 10);
  86     private Color roColor = new Color(187, 213, 238);
  87     private Surface surface;
  88     private Thread thread;
  89     private JPanel toolbarPanel;
  90     private JPanel sliderPanel;
  91     private JLabel label;
  92     private ToggleIcon bumpyIcon, rolloverIcon;
  93     private DecimalFormat decimalFormat = new DecimalFormat("000");
  94     protected boolean focus;
  95     public JToggleButton toggleB;
  96     public JButton printB;
  97     public JComboBox<String> screenCombo;
  98     public JToggleButton renderB, aliasB;
  99     public JToggleButton textureB, compositeB;
 100     public JButton startStopB;
 101     public JButton cloneB;
 102     public boolean issueRepaint = true;
 103     public JToolBar toolbar;
 104     public JSlider slider;
 105     public boolean doSlider;
 106     public boolean isExpanded;
 107 
 108     @SuppressWarnings("LeakingThisInConstructor")
 109     public Tools(Surface surface, DemoInstVarsAccessor demoInstVars) {
 110         this.surface = surface;
 111         this.demoInstVars = demoInstVars;
 112 
 113         setLayout(new BorderLayout());
 114 
 115         stopIcon = new ImageIcon(DemoImages.getImage("stop.gif", this));
 116         startIcon = new ImageIcon(DemoImages.getImage("start.gif", this));
 117         bumpyIcon = new ToggleIcon(this, LIGHT_GRAY);


 150 
 151         s = surface.Rendering == RenderingHints.VALUE_RENDER_SPEED
 152                 ? "Speed" : "Quality";
 153         renderB = addTool("R", "Rendering " + s, this);
 154 
 155         s = surface.texture != null ? "On" : "Off";
 156         textureB = addTool("T", "Texture " + s, this);
 157 
 158         s = surface.composite != null ? "On" : "Off";
 159         compositeB = addTool("C", "Composite " + s, this);
 160 
 161         Image printBImg = DemoImages.getImage("print.gif", this);
 162         printB = addTool(printBImg, "Print the Surface", this);
 163 
 164         if (surface instanceof AnimatingSurface) {
 165             Image stopImg = DemoImages.getImage("stop.gif", this);
 166             startStopB = addTool(stopImg, "Stop Animation", this);
 167             toolbar.setPreferredSize(new Dimension(6*25, 26));
 168         }
 169 
 170         screenCombo = new JComboBox<>();
 171         screenCombo.setPreferredSize(new Dimension(100, 18));
 172         screenCombo.setFont(font);
 173         for (String name : GlobalControls.screenNames) {
 174             screenCombo.addItem(name);
 175         }
 176         screenCombo.addActionListener(this);
 177         toolbarPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
 178         toolbarPanel.setLocation(0, 6);
 179         toolbarPanel.setVisible(false);
 180         toolbarPanel.add(toolbar);
 181         toolbarPanel.add(screenCombo);
 182         toolbarPanel.setBorder(new EtchedBorder());
 183         add(toolbarPanel);
 184 
 185         setPreferredSize(new Dimension(200, 8));
 186 
 187         if (surface instanceof AnimatingSurface) {
 188             sliderPanel = new JPanel(new BorderLayout());
 189             label = new JLabel(" Sleep = 030 ms");
 190             label.setForeground(BLACK);


< prev index next >