Example #1
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
Example #2
0
 public FigurePanel() {
   setLayout(new BorderLayout());
   JPanel panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(fs);
   panel.add(bp);
   JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, cp);
   sp.setPreferredSize(new Dimension(500, 400));
   sp.setDividerLocation(250);
   add(BorderLayout.CENTER, sp);
 }
Example #3
0
  public GLDemo() {
    super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false);

    DisplayOptions.addChangeListener(this);

    contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    gradientPanel = createGradientPanel();

    contentPane.add(gradientPanel, BorderLayout.CENTER);

    checkBox = new JCheckBox("Transparent", true);
    checkBox.setActionCommand("transparancy");
    checkBox.addActionListener(this);
    optionsPan = new JPanel();
    optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false));
    optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

    optionsPan.add(checkBox);

    runButton = new JToggleButton("Run");
    runButton.setActionCommand("run");
    runButton.setSelected(false);
    runButton.addActionListener(this);

    optionsPan.add(runButton);

    getContentPane().add(optionsPan, BorderLayout.SOUTH);
    setSize(300, 300);
    setLocation(300, 300);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(
                    new Runnable() {
                      public void run() {
                        stop();
                      }
                    })
                .start();
          }
        });
    setVisible(false);
  }
Example #4
0
  public static JPanel createGradientPanel() {
    JPanel gradientPanel =
        new JPanel() {
          Color c = Util.getBgColor();

          public void paintComponent(Graphics g) {
            ((Graphics2D) g)
                .setPaint(
                    new GradientPaint(0, 0, c.brighter(), getWidth(), getHeight(), c.darker()));
            g.fillRect(0, 0, getWidth(), getHeight());
          }
        };
    gradientPanel.setLayout(new BorderLayout());
    return gradientPanel;
  }
Example #5
0
  public OptionDialogFrame() {
    setTitle("OptionDialogTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    JPanel gridPanel = new JPanel();
    gridPanel.setLayout(new GridLayout(2, 3));

    typePanel = new ButtonPanel("Type", "Message", "Confirm", "Option", "Input");
    messageTypePanel =
        new ButtonPanel(
            "Message Type",
            "ERROR_MESSAGE",
            "INFORMATION_MESSAGE",
            "WARNING_MESSAGE",
            "QUESTION_MESSAGE",
            "PLAIN_MESSAGE");
    messagePanel = new ButtonPanel("Message", "String", "Icon", "Component", "Other", "Object[]");
    optionTypePanel =
        new ButtonPanel(
            "Confirm",
            "DEFAULT_OPTION",
            "YES_NO_OPTION",
            "YES_NO_CANCEL_OPTION",
            "OK_CANCEL_OPTION");
    optionsPanel = new ButtonPanel("Option", "String[]", "Icon[]", "Object[]");
    inputPanel = new ButtonPanel("Input", "Text field", "Combo box");

    gridPanel.add(typePanel);
    gridPanel.add(messageTypePanel);
    gridPanel.add(messagePanel);
    gridPanel.add(optionTypePanel);
    gridPanel.add(optionsPanel);
    gridPanel.add(inputPanel);

    // add a panel with a Show button

    JPanel showPanel = new JPanel();
    JButton showButton = new JButton("Show");
    showButton.addActionListener(new ShowAction());
    showPanel.add(showButton);

    add(gridPanel, BorderLayout.CENTER);
    add(showPanel, BorderLayout.SOUTH);
  }
Example #6
0
  /**
   * File Manager Frame
   *
   * @param frame parent frame
   */
  public FileManager(JFrame frame, FileFilter filter) {
    super("File Manager");

    FileTree ftree = new FileTree(new File(System.getProperty("user.dir")), frame, filter);
    JScrollPane jsp = new JScrollPane(ftree);
    JPanel pane = (JPanel) getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(jsp, BorderLayout.CENTER);
    setJMenuBar(makeMenuBar(pane, ftree));
    pane.add(getFileFileterComboBox(ftree), BorderLayout.SOUTH);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    jsp.setPreferredSize(new Dimension(210, (int) (screen.getHeight() / 2)));
    pack();

    int yloc = (int) ((screen.getHeight() - getHeight()) / 2);
    setLocation(0, yloc);
    setVisible(true);
  }
  /**
   * The GPropertiesDialog class constructor.
   *
   * @param gui the GUI class
   */
  public GPropertiesDialog(GUI gui) {
    // superclass constructor
    super(gui, "Properties", false);
    objects = new ObjectContainer();

    // gui
    this.gui = gui;

    // set the fixed size
    setSize(260, 350);
    setResizable(false);
    setLayout(null);

    // set up panels for stuff
    pane = new JTabbedPane();

    // add the tabbed panel
    tabbedPanePanel = new JPanel();
    tabbedPanePanel.add(pane);
    tabbedPanePanel.setLayout(null);
    this.getContentPane().add(tabbedPanePanel);
    tabbedPanePanel.setBounds(0, 0, this.getWidth(), 280);
    pane.setBounds(0, 0, tabbedPanePanel.getWidth(), tabbedPanePanel.getHeight());

    // set up buttons
    apply = new JButton("Apply");
    apply.setBounds(150, 290, 80, 26);
    this.getContentPane().add(apply);

    close = new JButton("Close");
    close.setBounds(50, 290, 80, 26);
    this.getContentPane().add(close);

    addPanel(new GPropertiesPanelCustomObject(gui.getGMap()), "Object");

    // add listeners
    addMouseListener(this);
    apply.addItemListener(this);
    apply.addActionListener(this);
    close.addItemListener(this);
    close.addActionListener(this);
  }
Example #8
0
  static void buildGUI() {
    // Need this size to balance axes.
    frame.setSize(520, 690);
    frame.setTitle("DrawTool");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    Container cPane = frame.getContentPane();

    // Status label on top. Unused for now.
    statusLabel.setOpaque(true);
    statusLabel.setBackground(Color.white);
    cPane.add(statusLabel, BorderLayout.NORTH);

    // Build the input/output elements at the bottom.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.black));
    panel.setBackground(inputPanelColor);
    panel.setLayout(new GridLayout(2, 1));
    panel.add(outputLabel);
    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(inputPanelColor);
    bottomPanel.add(inputField);
    bottomPanel.add(new JLabel("   "));
    JButton enterButton = new JButton("Enter");
    enterButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            hasEntered = true;
          }
        });
    bottomPanel.add(enterButton);
    panel.add(bottomPanel);
    if (!sequencingOn) {
      cPane.add(panel, BorderLayout.SOUTH);
    }

    // Drawing in the center.
    drawArea = new DrawTool();
    if (sequencingOn) {
      frame.addKeyListener(
          new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
              handleKeyTyped(e);
            }
          });
    }
    cPane.add(drawArea, BorderLayout.CENTER);

    drawArea.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            handleMouseClick(e);
          }

          public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
          }
        });

    drawArea.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
          }
        });
  }
Example #9
0
  /**
   * @param filenames
   * @exception Exception if internal error
   */
  public void loadMultiPanelFromSpecifiedFiles(String filenames[]) throws Exception {

    int nFiles = filenames.length;

    SingleImagePanel imagePanels[] = new SingleImagePanel[nFiles];

    String orientations[][] = new String[nFiles][];
    String views[] = new String[nFiles];
    String lateralityViewAndModifiers[] = new String[nFiles];
    String lateralities[] = new String[nFiles];
    int widths[] = new int[nFiles];
    int heights[] = new int[nFiles];
    PixelSpacing spacing[] = new PixelSpacing[nFiles];

    String rowOrientations[] = new String[nFiles];
    String columnOrientations[] = new String[nFiles];

    HashMap eventContexts = new HashMap();

    double maximumHorizontalExtentInMm = 0;
    double maximumVerticalExtentInMm = 0;

    StructuredReport sr[] = new StructuredReport[nFiles];

    int nImages = 0;
    int nCAD = 0;
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    for (int f = 0; f < nFiles; ++f) {
      try {
        String filename = filenames[f];
        DicomInputStream distream = null;
        InputStream in = classLoader.getResourceAsStream(filename);
        if (in != null) {
          distream = new DicomInputStream(in);
        } else {
          distream = new DicomInputStream(new File(filename));
        }
        AttributeList list = new AttributeList();
        list.read(distream);
        if (list.isImage()) {
          int i = nImages++;
          System.err.println("IMAGE [" + i + "] is file " + f + " (" + filenames[f] + ")");

          orientations[i] = getPatientOrientation(list);
          // System.err.println("IMAGE ["+i+"] orientation="+(orientations[i] == null &&
          // orientations[i].length == 2 ? "" : (orientations[i][0] + " " + orientations[i][1])));
          views[i] = getView(list);
          // System.err.println("IMAGE ["+i+"] view="+views[i]);
          lateralityViewAndModifiers[i] = getImageLateralityViewModifierAndViewModifier(list);
          // System.err.println("IMAGE ["+i+"]
          // lateralityViewAndModifiers="+lateralityViewAndModifiers[i]);
          // System.err.println("File "+filenames[f]+": "+lateralityViewAndModifiers[i]);
          lateralities[i] = getLaterality(list);
          // System.err.println("IMAGE ["+i+"] laterality="+lateralities[i]);
          spacing[i] = new PixelSpacing(list);
          // System.err.println("IMAGE ["+i+"] spacing="+spacing[i]);

          SourceImage sImg = new SourceImage(list);
          BufferedImage img = sImg.getBufferedImage();

          widths[i] = sImg.getWidth();
          heights[i] = sImg.getHeight();

          boolean shareVOIEventsInStudy =
              false; // does not seem to work anyway, since adding VOITransform to panel constructor
                     // :(

          EventContext eventContext = new EventContext(Integer.toString(i));

          SingleImagePanel imagePanel = makeNewImagePanel(sImg, eventContext);
          imagePanel.setDemographicAndTechniqueAnnotations(
              new DemographicAndTechniqueAnnotations(list),
              "SansSerif",
              Font.PLAIN,
              10,
              Color.pink);
          imagePanel.setOrientationAnnotations(
              new OrientationAnnotations(rowOrientations[i], columnOrientations[i]),
              "SansSerif",
              Font.PLAIN,
              20,
              Color.pink);
          imagePanel.setPixelSpacingInSourceImage(
              spacing[i].getSpacing(), spacing[i].getDescription());
          if (Attribute.getSingleStringValueOrEmptyString(list, TagFromName.VOILUTFunction)
              .equals("SIGMOID")) {
            imagePanel.setVOIFunctionToLogistic();
          }
          imagePanels[i] = imagePanel;
        } else {
          throw new DicomException("Unsupported SOP Class in file " + filenames[f]);
        }
      } catch (Exception e) { // FileNotFoundException,IOException,DicomException
        e.printStackTrace(System.err);
      }
    }

    // int imagesPerRow = nImages;			// i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4
    // int imagesPerCol = 1;

    int imagesPerRow = nImages >= 8 ? 8 : nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4
    int imagesPerCol =
        (nImages - 1) / imagesPerRow + 1; // i.e., 1 -> 1, 2 -> 2, 4 -> 1, 5 -> 2, 8 -> 2

    int singleWidth = frameWidth / imagesPerRow;
    int singleHeight = frameHeight / imagesPerCol;

    if (nImages == 1 && singleWidth > singleHeight) {
      singleWidth =
          singleWidth / 2; // use only half the screen for a single view and a landscape monitor
    }

    for (int i = 0; i < nImages; ++i) {
      DisplayedAreaSelection displayedAreaSelection = null;
      displayedAreaSelection =
          new DisplayedAreaSelection(
              widths[i],
              heights[i],
              0,
              0,
              widths[i],
              heights[i],
              true, // in case spacing was not supplied
              0,
              0,
              0,
              0,
              0,
              false /*crop*/);
      imagePanels[i].setDisplayedAreaSelection(displayedAreaSelection);
      imagePanels[i].setPreTransformImageRelativeCoordinates(null);
    }

    SingleImagePanel.deconstructAllSingleImagePanelsInContainer(multiPanel);
    multiPanel.removeAll();
    multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow));
    multiPanel.setBackground(Color.black);

    for (int x = 0; x < imagesPerCol; ++x) {
      for (int y = 0; y < imagesPerRow; ++y) {
        int i = x * imagesPerRow + y;
        if (i < nImages) {
          imagePanels[i].setPreferredSize(new Dimension(singleWidth, singleHeight));
          multiPanel.add(imagePanels[i]);
        }
      }
    }
    frame.getContentPane().validate();
    frame.getContentPane().repaint();
  }
Example #10
0
 public void geInit() {
   JopSpider.setSystemName("䣷D‘ú·D‘ú·p—uÄŸ¢·{¨· s¨·È‡Æ¿ç韷D‘ú·D‘ú·x—u s¨·");
   engine.setAnimationScanTime(500);
   engine.setScanTime(500);
   size = new Dimension(711, 169);
   Dimension dsize = new Dimension(localPanel.original_width, localPanel.original_height);
   this.addComponentListener(new AspectRatioListener(this, size));
   contentPane = (JPanel) this.getContentPane();
   contentPane.setLayout(borderLayout1);
   if (scrollbar) contentPane.add(new JScrollPane(localPanel), BorderLayout.CENTER);
   else contentPane.add(localPanel, BorderLayout.CENTER);
   contentPane.setOpaque(true);
   localPanel.setLayout(new RatioLayout()); // scaletest
   localPanel.setOpaque(true);
   localPanel.setBackground(GeColor.getColor(51, GeColor.NO_COLOR));
   this.setSize(size);
   if (engine.isInstance()) setTitle(engine.getInstance());
   else this.setTitle("JopcMessagehandler");
   pwr_indsquare2 = new pwr_indsquare(session);
   pwr_indsquare2.setBounds(new Rectangle(133, 78, 15, 16));
   localPanel.add(pwr_indsquare2, new Proportion(pwr_indsquare2.getBounds(), dsize));
   pwr_indsquare3 = new pwr_indsquare(session);
   pwr_indsquare3.setBounds(new Rectangle(133, 99, 15, 16));
   localPanel.add(pwr_indsquare3, new Proportion(pwr_indsquare3.getBounds(), dsize));
   pwr_valuelong4 = new pwr_valuelong(session);
   pwr_valuelong4.setBounds(new Rectangle(151, 77, 535, 17));
   pwr_valuelong4.setBorderColor(33);
   localPanel.add(pwr_valuelong4, new Proportion(pwr_valuelong4.getBounds(), dsize));
   pwr_valuelong5 = new pwr_valuelong(session);
   pwr_valuelong5.setBounds(new Rectangle(151, 99, 535, 17));
   pwr_valuelong5.setBorderColor(33);
   localPanel.add(pwr_valuelong5, new Proportion(pwr_valuelong5.getBounds(), dsize));
   pwr_valuesmall7 = new pwr_valuesmall(session);
   pwr_valuesmall7.setBounds(new Rectangle(133, 10, 54, 17));
   pwr_valuesmall7.setFillColor(31);
   pwr_valuesmall7.setBorderColor(33);
   localPanel.add(pwr_valuesmall7, new Proportion(pwr_valuesmall7.getBounds(), dsize));
   pwr_valuesmall9 = new pwr_valuesmall(session);
   pwr_valuesmall9.setBounds(new Rectangle(133, 31, 54, 17));
   pwr_valuesmall9.setFillColor(31);
   pwr_valuesmall9.setBorderColor(33);
   localPanel.add(pwr_valuesmall9, new Proportion(pwr_valuesmall9.getBounds(), dsize));
   pwr_valuesmall11 = new pwr_valuesmall(session);
   pwr_valuesmall11.setBounds(new Rectangle(133, 54, 54, 17));
   pwr_valuesmall11.setFillColor(31);
   pwr_valuesmall11.setBorderColor(33);
   localPanel.add(pwr_valuesmall11, new Proportion(pwr_valuesmall11.getBounds(), dsize));
   pwr_indsquare2.dd.setDynType(33554432);
   pwr_indsquare2.dd.setActionType(0);
   pwr_indsquare2.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynStatusColor(pwr_indsquare2.dd, "$node.ProcStatus[6]##status", 38)
       });
   pwr_indsquare3.dd.setDynType(33554432);
   pwr_indsquare3.dd.setActionType(0);
   pwr_indsquare3.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynStatusColor(pwr_indsquare3.dd, "$node.ProcMsgSeverity[6]##status", 38)
       });
   pwr_valuelong4.dd.setDynType(1025);
   pwr_valuelong4.dd.setActionType(0);
   pwr_valuelong4.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuelong4.dd, "$node.ProcStatus[6]##Status", "%1m")
       });
   pwr_valuelong5.dd.setDynType(1025);
   pwr_valuelong5.dd.setActionType(0);
   pwr_valuelong5.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuelong5.dd, "$node.ProcMessage[6]##String80", "%s")
       });
   pwr_valuesmall7.dd.setDynType(1025);
   pwr_valuesmall7.dd.setActionType(0);
   pwr_valuesmall7.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall7.dd, "$object.EventListSize##Int32", "%d")
       });
   pwr_valuesmall9.dd.setDynType(1025);
   pwr_valuesmall9.dd.setActionType(0);
   pwr_valuesmall9.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall9.dd, "$object.EventLogSize##Int32", "%d")
       });
   pwr_valuesmall11.dd.setDynType(1025);
   pwr_valuesmall11.dd.setActionType(0);
   pwr_valuesmall11.dd.setElements(
       new GeDynElemIfc[] {
         new GeDynValue(pwr_valuesmall11.dd, "$object.MaxApplAlarms##Int32", "%d")
       });
   engine.setFrameReady();
 }
Example #11
0
  ////////////// methods to create the interactive visualizer ////////////////////////
  private void createMainFrame() {
    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    Container contentPane = mainFrame.getContentPane();
    // contentPane.setLayout(new BorderLayout());

    // creates the control panel
    controlPanel = new JPanel(null);
    controlPanel.setLayout(new FlowLayout());
    makeSoundVis();
    mainFrame.addComponentListener(new ResizeHandler());

    // setting up the play sound button
    playBtn = new JButton("Play");
    playBtn.setEnabled(true);
    playBtn.setToolTipText("Play the  sound");
    playBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            stopBtn.setEnabled(true);
            pauseBtn.setEnabled(true);
            playBtn.setEnabled(false);
            playSelectionBtn.setEnabled(false);
            zoomInBtn.setEnabled(false);
            zoomOutBtn.setEnabled(false);
            isPlaying = true;
            myHelper.play();
          }
        });
    controlPanel.add(playBtn);

    // setting up the play selection button
    playSelectionBtn = new JButton("Play Selection");
    playSelectionBtn.setEnabled(false);
    playSelectionBtn.setToolTipText("Play sound between start and stop index");
    playSelectionBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            playSelClicked++;
            stopBtn.setEnabled(true);
            pauseBtn.setEnabled(true);
            playSelectionBtn.setEnabled(false);
            playBtn.setEnabled(false);
            zoomInBtn.setEnabled(false);
            zoomOutBtn.setEnabled(false);
            isPlaying = false;
            if (playSelClicked == 1) {
              myHelper.playInRange(
                  wavePanel.getSelectionStartSample(), wavePanel.getSelectionEndSample());
            } else {
              myHelper.play();
            }
          }
        });
    controlPanel.add(playSelectionBtn);

    // setting up the stop button
    stopBtn = new JButton("Stop");
    stopBtn.setEnabled(false);
    stopBtn.setToolTipText("Stop playing the sound");
    stopBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            myHelper.stop();
            stopBtn.setEnabled(false);
            pauseBtn.setEnabled(false);
            playBtn.setEnabled(true);
            if (wavePanel.moreZoomInScope()) {
              zoomInBtn.setEnabled(true);
              playSelectionBtn.setEnabled(true);
            }

            if (wavePanel.moreZoomOutScope()) {
              zoomOutBtn.setEnabled(true);
            }
            playSelClicked = 0;
            isPlaying = false;
          }
        });
    controlPanel.add(stopBtn);

    // setting up the stop button
    pauseBtn = new JButton("Pause");
    pauseBtn.setEnabled(false);
    pauseBtn.setToolTipText("Pause the sound");
    pauseBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            myHelper.pause();
            if (isPlaying) {
              playBtn.setEnabled(true);
            } else {
              playSelectionBtn.setEnabled(true);
            }
          }
        });
    controlPanel.add(pauseBtn);

    // setting up the zoom  button
    zoomInBtn = new JButton("Zoom In");
    zoomInBtn.setEnabled(false);
    zoomInBtn.setToolTipText("Click to see the samples within your selection");
    zoomInBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            handleZoomIn();
          }
        });
    controlPanel.add(zoomInBtn);

    // setting up the zoom  button
    zoomOutBtn = new JButton("Zoom Out");
    zoomOutBtn.setEnabled(false);
    zoomOutBtn.setToolTipText("Click to zoom out");
    zoomOutBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            handleZoomOut();
          }
        });
    controlPanel.add(zoomOutBtn);

    controlPanel.setBounds(0, controlLocY, frameWidth, controlHeight);
    contentPane.add(controlPanel);

    contentPane.add(wavePanel);
    contentPane.add(overViewPanel);
    wavePanel.setBounds(0, waveLocY, frameWidth, waveHeight);

    // controlPanel.removeAll();
    // controlPanel.setBackground(Color.CYAN);

    mainFrame.setSize(frameWidth, frameHeight);

    overViewPanel.init();
    wavePanel.init();
    //
    // mainFrame.pack();
    // mainFrame.setResizable(false);
    // mainFrame.validate();

    mainFrame.setVisible(true);
    overViewPanel.setBounds(0, 0, frameWidth, overViewHeight);

    // mainFrame.validate();

  }
Example #12
0
  public void initUI(int x, int y) {
    setVisible(true);

    loadIcons();

    dx = x;
    dy = y;
    text_height = getFontMetrics(getFont()).getHeight();
    plane_width = icon_size;
    plane_height = icon_size + text_height + text_gap;
    radar_area_width = grid_size * dx;
    radar_area_height = grid_size * dy;

    getContentPane().setLayout(new BorderLayout());

    radarArea = new RadarPane();
    radarArea.setMinimumSize(new Dimension(radar_area_width, radar_area_height));
    radarArea.setPreferredSize(new Dimension(radar_area_width, radar_area_height));
    getContentPane().add(radarArea, BorderLayout.CENTER);

    radarArea.backImage =
        new BufferedImage(radar_area_width, radar_area_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = radarArea.backImage.createGraphics();
    g.setBackground(back_color);
    g.setColor(rim_color);
    g.fillRect(0, 0, radar_area_width, radar_area_height);
    g.setColor(back_color);
    g.fillRect(convPos(0), convPos(0), radar_area_width - grid_size, radar_area_height - grid_size);
    g.setColor(line_color);
    int i, j;
    for (i = 0; i < dx; i++)
      for (j = 0; j < dy; j++) g.draw(new Rectangle(convPos(i) - 1, convPos(j) - 1, 1, 1));

    radarArea.backIcon = new ImageIcon(radarArea.backImage);
    radarArea.back = new JLabel(radarArea.backIcon);
    radarArea.back.setBounds(0, 0, radar_area_width, radar_area_height);
    radarArea.add(radarArea.back, new Integer(0));

    infoArea = new JPanel();
    infoArea.setMinimumSize(new Dimension(info_area_width, radar_area_height));
    infoArea.setPreferredSize(new Dimension(info_area_width, radar_area_height));
    infoArea.setLayout(new GridLayout(27, 1));
    infoTopLine = new Label(" ");
    infoArea.add(infoTopLine);
    getContentPane().add(infoArea, BorderLayout.EAST);

    inputArea = new JLabel("          ");
    getContentPane().add(inputArea, BorderLayout.SOUTH);

    controlArea = new JPanel();
    newButton = new JButton("New");
    newButton.setActionCommand("New");
    newButton.addActionListener(this);
    newButton.setEnabled(false);
    newButton.setFocusable(false);
    exitButton = new JButton("Exit");
    exitButton.setActionCommand("Exit");
    exitButton.addActionListener(this);
    exitButton.setFocusable(false);
    controlArea.add(newButton);
    controlArea.add(exitButton);
    getContentPane().add(controlArea, BorderLayout.NORTH);

    pack();
  }
Example #13
0
  /**
   * inti the UI and some params
   *
   * @param none
   */
  public void initUI() {
    // cNextBlockDC.setLayout(new BorderLayout());
    getContentPane().setLayout(null);
    // the total panel
    JPanel outer = new JPanel();
    getContentPane().add(outer);
    outer.setBounds(4, 4, frameWeight - 20, frameHeight - 50);
    outer.setBorder(BorderFactory.createTitledBorder("Game DC"));
    outer.setLayout(null);

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(null);
    // the panel to show next block
    JPanel tipNext = new JPanel();
    tipNext.setBounds(10, 30, 130, 80);
    tipNext.setBorder(BorderFactory.createTitledBorder("Next Block"));
    tipNext.setLayout(null);
    cNextBlockDC.setBounds(25, 20, 48, 48);
    tipNext.add(cNextBlockDC);
    rightPanel.add(tipNext);

    // the panel to show the score
    JPanel playerScore = new JPanel();
    playerScore.setBounds(10, 110, 130, 40);
    playerScore.setBorder(BorderFactory.createTitledBorder("Score"));
    playerScore.setLayout(null);
    m_lTotalScore.setBounds(40, 15, 100, 20);
    playerScore.add(m_lTotalScore);
    rightPanel.add(playerScore);

    // the panel to show the button
    JPanel buttonArea = new JPanel();
    buttonArea.setBounds(10, 160, 130, 170);
    buttonArea.setBorder(BorderFactory.createTitledBorder("Game Control"));
    buttonArea.setLayout(null);
    m_bGameHalt.setBounds(10, 30, 110, 30);
    buttonArea.add(m_bGameHalt);
    m_bGameStart.setBounds(10, 62, 110, 30);
    buttonArea.add(m_bGameStart);
    m_bGameOver.setBounds(10, 94, 110, 30);
    buttonArea.add(m_bGameOver);
    m_bVoiceControl.setBounds(10, 126, 110, 30);
    buttonArea.add(m_bVoiceControl);

    rightPanel.add(buttonArea);
    // the Panel to show the tips for the game
    JPanel gameTip = new JPanel();
    gameTip.setBounds(10, 330, 130, 160);
    gameTip.setBorder(BorderFactory.createTitledBorder("Game Tip"));
    gameTip.setLayout(null);
    m_lGameTip.setBounds(10, 20, 130, 100);
    Font fnt = new Font("楷体_GB2312", Font.ITALIC, 15);
    m_lGameTip.setText(
        "<html><body>"
            + "<font style='color:#2f4f4f;size:10px;'>"
            + "1.由方向键控制游戏<br/>,向上有变形;<br/>2."
            + "语音控制命令见配<br/>置文件;<br/>3.Author:");
    // the link for blog
    JLabel linkForBlog =
        new JLabel("<html><body><a style='color:#00755e;' href ='#'>kymo</a></body></html>");
    linkForBlog.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkForBlog.setBounds(20, 113, 130, 15);
    // add mouse event
    linkForBlog.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            //// System.out.println("click !");
            try {
              Desktop.getDesktop().browse(new java.net.URI(kymoBlog));
            } catch (IOException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            } catch (URISyntaxException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    // the link to open voice xml file
    JLabel linkForXml =
        new JLabel(
            "<html><body><a style='color:#00755e;' href ='#'>open voice xml</a></body></html>");
    linkForXml.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkForXml.setBounds(20, 128, 130, 15);
    // add mouse event
    linkForXml.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // JLabel xmlFileContent = new JLabel();
            try {
              Runtime.getRuntime()
                  .exec("cmd /c start " + System.getProperty("user.dir") + "\\voice.xml");
            } catch (IOException ex) {
              //// System.out.println(ex);
            }
          }
        });
    gameTip.add(linkForBlog);
    gameTip.add(linkForXml);
    gameTip.add(m_lGameTip);
    rightPanel.add(gameTip);

    // pack();
    rightPanel.setBounds(340, 30, 150, 500);
    rightPanel.setBorder(BorderFactory.createTitledBorder("Game Control&Tips"));

    outer.add(rightPanel);
    cGameDc = new DrawComponent(this, cTetrisBlock);
    cGameDc.setBounds(30, 30, 300, 500);
    outer.add(cGameDc);
    setVisible(true);
    setResizable(false);
    pack();
    this.setSize(frameWeight, frameHeight);
    this.setLocation(frameLocaX, frameLocaY);
    m_bGameHalt.addActionListener((ActionListener) this);
    m_bGameStart.addActionListener((ActionListener) this);
    m_bGameOver.addActionListener((ActionListener) this);
    m_bVoiceControl.addActionListener((ActionListener) this);
    // if the windows is close ,the game thread will end
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            isGameOver = true;
            System.exit(0);
          }
        });

    // the listen of the keyboard
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              @Override
              public void eventDispatched(AWTEvent event) {
                // TODO Auto-generated method stub
                if (((KeyEvent) event).getID() == KeyEvent.KEY_RELEASED) isKeyPressed = false;
                if (((KeyEvent) event).getID() == KeyEvent.KEY_PRESSED) {
                  // 放入自己的键盘监听事件
                  // ((KeyEvent) event).getKeyCode();// 获取按键的code
                  // ((KeyEvent) event).getKeyChar();//
                  // 获取按键的字符////System.out.println(e.getKeyCode());
                  if (!isGameHalt && isGameStart) {
                    if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_RIGHT) {
                      if (!isCoordinateLock) {
                        isKeyPressed = true;
                        if (!isRightToEnd(cTetrisBlock.m_blockRightX))
                          cTetrisBlock.setCoordinateXY(
                              cTetrisBlock.getTetrisCoordinateX() + 20,
                              cTetrisBlock.getTetrisCoordinateY());
                        cGameDc.repaint();
                      }
                    } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_LEFT) {
                      if (!isCoordinateLock) {
                        isKeyPressed = true;
                        /*
                        for(int j = 0; j < 4; j ++)
                        	//System.out.print(cTetrisBlock.m_blockLeftX[j] + " ");
                        */
                        //// System.out.println();
                        if (!isLeftToEnd(cTetrisBlock.m_blockLeftX))
                          cTetrisBlock.setCoordinateXY(
                              cTetrisBlock.getTetrisCoordinateX() - 20,
                              cTetrisBlock.getTetrisCoordinateY());
                        cGameDc.repaint();
                      }
                    } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_DOWN) {
                      if (!isCoordinateLock) {
                        isKeyPressed = true;
                        if (!isToEnd(cTetrisBlock.m_blockBottomY))
                          cTetrisBlock.setCoordinateXY(
                              cTetrisBlock.getTetrisCoordinateX(),
                              cTetrisBlock.getTetrisCoordinateY() + 20);
                        cGameDc.repaint();
                      }
                    } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_UP) {
                      if (!isCoordinateLock) {
                        isKeyPressed = true;
                        isTransforStart = true;
                        cTetrisBlock.tetrisBlockShapeTransformation(m_blockGrid);
                        cGameDc.repaint();
                        isTransforStart = false;
                      }
                    }
                  }
                }
              }
            },
            AWTEvent.KEY_EVENT_MASK);
  }
Example #14
0
  public void createLayout() {
    top = new JPanel();
    wModel.panel.add(top, BorderLayout.NORTH);
    top.setLayout(new BorderLayout(0, 0));

    bottom = new JPanel();
    wModel.panel.add(bottom, BorderLayout.SOUTH);
    bottom.setLayout(new BorderLayout(0, 0));

    center = new JPanel();
    wModel.panel.add(center, BorderLayout.CENTER);
    center.setLayout(new BorderLayout(0, 0));

    // Spielfeld
    gameField = new JPanel();
    gameField.setPreferredSize(new Dimension(550, 800));
    wModel.panel.add(gameField, BorderLayout.WEST);
    gameField.setLayout(new GridLayout(4, 4, 5, 5));

    /**
     * *********************************************************** Sidebar
     * ************************************************************
     */
    dates = new JPanel();
    dates.setLayout(new BorderLayout());
    JLabel background = new JLabel(new ImageIcon("../gfx/datesBack.png"));
    dates.add(background);

    GridBagLayoutModel gblModel = new GridBagLayoutModel();
    GridBagLayout gbl = new GridBagLayout();
    background.setLayout(gbl);

    l1 = new JLabel(new ImageIcon("../gfx/spieler1.png"));
    points1 = new JLabel(new ImageIcon("../gfx/punkte.png"));
    points1Num = new JLabel("0");
    l2 = new JLabel(new ImageIcon("../gfx/spieler2.png"));
    points2 = new JLabel(new ImageIcon("../gfx/punkte.png"));
    points2Num = new JLabel("0");

    JLabel namePlayer1 = new JLabel(player1.getName());
    JLabel namePlayer2 = new JLabel(player2.getName());

    JButton end = new JButton("Beenden");

    gblModel.addComponent(background, gbl, l1, 0, 2, 1, 1, 1.0, 0.5);
    gblModel.addComponent(background, gbl, namePlayer1, 1, 2, 1, 1, 1.0, 0.5);
    gblModel.addComponent(background, gbl, points1, 0, 3, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, points1Num, 1, 3, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, l2, 0, 4, 1, 1, 1.0, 1.0);
    gblModel.addComponent(background, gbl, namePlayer2, 1, 4, 1, 1, 1.0, 1.0);
    gblModel.addComponent(background, gbl, points2, 0, 5, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, points2Num, 1, 5, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, end, 1, 6, 1, 1, 0.0, 0.2);

    wModel.panel.add(dates, BorderLayout.EAST);

    end.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
  }
Example #15
0
  public LJ3MDApp() {
    tNum.setHorizontalAlignment(JTextField.CENTER);
    tTemp.setHorizontalAlignment(JTextField.CENTER);
    tRho.setHorizontalAlignment(JTextField.CENTER);
    tSpeed.setHorizontalAlignment(JTextField.CENTER);

    tAvK.setHorizontalAlignment(JTextField.RIGHT);
    tAvU.setHorizontalAlignment(JTextField.RIGHT);
    tAvp.setHorizontalAlignment(JTextField.RIGHT);

    float[] aveKing = new float[501];
    float[] avePot = new float[501];
    float[] aveEn = new float[501];

    JFrame box = new JFrame();
    box.setLayout(new BorderLayout());
    box.setSize(1000, 1000);
    box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    cpnl = new JPanel(); // create a panel for controls
    cpnl.setLayout(new GridLayout(18, 2));
    box.add(cpnl, BorderLayout.EAST);

    // add controls
    cpnl.add(bStart);
    bStart.addActionListener(this);

    cpnl.add(bReset);
    bReset.addActionListener(this);

    cpnl.add(new JLabel(" N:"));
    tNum.addActionListener(this);
    cpnl.add(tNum);

    cpnl.add(new JLabel(" Density (\u03c1):"));
    tRho.addActionListener(this);
    cpnl.add(tRho);

    cpnl.add(new JLabel(" Steps/frame:"));
    tSpeed.addActionListener(this);
    cpnl.add(tSpeed);

    cpnl.add(bTstat);
    bTstat.addActionListener(this);

    cpnl.add(bPot);
    bPot.addActionListener(this);

    cpnl.add(new JLabel(" < K/N > :"));
    tAvK.setEditable(false);
    cpnl.add(tAvK);

    cpnl.add(new JLabel(" Temperature:"));
    tTemp.setEditable(false);
    cpnl.add(tTemp);

    cpnl.add(new JLabel(" < U/N > :"));
    tAvU.setEditable(false);
    cpnl.add(tAvU);

    cpnl.add(new JLabel(" < pressure > :"));
    tAvp.setEditable(false);
    cpnl.add(tAvp);

    cpnl.add(bRetime);
    bRetime.addActionListener(this);

    spnl = new JPanel(); // create a panel for status
    box.add(spnl, BorderLayout.SOUTH);
    lStatus.setFont(new Font("Courier", 0, 12));
    spnl.add(lStatus);

    canvas = new XYZCanvas();
    box.add(canvas, BorderLayout.CENTER);

    timer = new Timer(delay, this);
    timer.start();
    //        timer.stop();
    box.setVisible(true);
  }